@uipath/orchestrator-tool 1.207.0 → 1.208.0-preview.410

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,305 @@
1
1
  import {
2
2
  getFileSystem2
3
- } from "./tool-x8dsz8c6.js";
3
+ } from "./tool-afmw3cc4.js";
4
4
  import {
5
5
  __require
6
6
  } from "./tool-epsr41wx.js";
7
7
 
8
+ // ../common/src/telemetry/telemetry-dimensions.ts
9
+ var BaseDimensions = {
10
+ ApplicationName: "ApplicationName",
11
+ ProductVersion: "ProductVersion",
12
+ InstallationId: "InstallationId",
13
+ CloudUserId: "CloudUserId",
14
+ CloudTenantId: "CloudTenantId",
15
+ CloudOrganizationId: "CloudOrganizationId",
16
+ IsInternalUser: "IsInternalUser",
17
+ Environment: "Environment",
18
+ BaseUrl: "BaseUrl",
19
+ Region: "Region",
20
+ Agent: "Agent",
21
+ AgentVersion: "AgentVersion",
22
+ AgentModel: "AgentModel",
23
+ ToolName: "ToolName",
24
+ ToolVersion: "ToolVersion",
25
+ ExecutionContext: "ExecutionContext",
26
+ CiProvider: "CiProvider",
27
+ SessionIdSource: "SessionIdSource",
28
+ SessionId: "SessionId",
29
+ HostApp: "HostApp",
30
+ HostAppSource: "HostAppSource"
31
+ };
32
+ var CommandDimensions = {
33
+ IsCommand: "IsCommand",
34
+ IsReexec: "IsReexec",
35
+ CommandName: "CommandName",
36
+ ExitCode: "ExitCode",
37
+ TerminalOutcome: "TerminalOutcome",
38
+ ErrorClass: "ErrorClass",
39
+ TerminalSignal: "TerminalSignal",
40
+ ErrorMessage: "ErrorMessage",
41
+ SkillName: "SkillName",
42
+ ProductArea: "ProductArea",
43
+ Mode: "Mode"
44
+ };
45
+ var ProjectDimensions = {
46
+ ProjectKey: "ProjectKey",
47
+ ProjectType: "ProjectType",
48
+ ProjectIdentityStatus: "ProjectIdentityStatus",
49
+ SolutionKey: "SolutionKey",
50
+ SolutionProjectKey: "SolutionProjectKey",
51
+ SolutionIdentityStatus: "SolutionIdentityStatus",
52
+ PreviousSolutionKey: "PreviousSolutionKey",
53
+ PreviousProjectKey: "PreviousProjectKey"
54
+ };
55
+ var GUID_KEY_DIMENSIONS = new Set([
56
+ ProjectDimensions.ProjectKey,
57
+ ProjectDimensions.SolutionKey,
58
+ ProjectDimensions.SolutionProjectKey,
59
+ ProjectDimensions.PreviousSolutionKey,
60
+ ProjectDimensions.PreviousProjectKey
61
+ ]);
62
+ var ShipDimensions = {
63
+ ShipKind: "ShipKind",
64
+ Target: "Target",
65
+ ProjectType: "ProjectType",
66
+ ProjectTypes: "ProjectTypes",
67
+ ArtifactCorrelationKey: "ArtifactCorrelationKey",
68
+ PackageName: "PackageName",
69
+ PackageVersion: "PackageVersion",
70
+ PackageVersionKey: "PackageVersionKey",
71
+ DeploymentKey: "DeploymentKey",
72
+ SolutionId: "SolutionId",
73
+ FolderKey: "FolderKey",
74
+ FeedId: "FeedId"
75
+ };
76
+ var ErrorDimensions = {
77
+ Result: "Result",
78
+ ErrorCode: "ErrorCode",
79
+ Retry: "Retry",
80
+ ErrorMessage: "ErrorMessage",
81
+ HttpStatus: "HttpStatus",
82
+ UpstreamErrorCode: "UpstreamErrorCode"
83
+ };
84
+ var AuthDimensions = {
85
+ AuthenticationMethod: "AuthenticationMethod",
86
+ Success: "Success",
87
+ Reason: "Reason"
88
+ };
89
+ var SkillsDimensions = {
90
+ SchemaVersion: "SchemaVersion",
91
+ AgentType: "AgentType",
92
+ SkillsVersion: "SkillsVersion",
93
+ UipSubcommand: "UipSubcommand",
94
+ FileExtension: "FileExtension",
95
+ SubagentModel: "SubagentModel",
96
+ SubagentType: "SubagentType",
97
+ PermissionMode: "PermissionMode",
98
+ EffortLevel: "EffortLevel",
99
+ SessionSource: "SessionSource",
100
+ Outcome: "Outcome",
101
+ DurationMs: "DurationMs",
102
+ Source: "Source"
103
+ };
104
+ var PackagerDimensions = {
105
+ ProjectId: "ProjectId",
106
+ ProjectType: "ProjectType",
107
+ SolutionId: "SolutionId"
108
+ };
109
+ var ScopeDimensions = {
110
+ FolderId: "FolderId"
111
+ };
112
+ var ID_DIMENSIONS = new Set([
113
+ BaseDimensions.CloudUserId,
114
+ BaseDimensions.CloudTenantId,
115
+ BaseDimensions.CloudOrganizationId,
116
+ BaseDimensions.InstallationId,
117
+ ShipDimensions.ArtifactCorrelationKey,
118
+ ShipDimensions.PackageVersionKey,
119
+ ShipDimensions.DeploymentKey,
120
+ ShipDimensions.SolutionId,
121
+ ShipDimensions.FolderKey,
122
+ ShipDimensions.FeedId,
123
+ PackagerDimensions.ProjectId
124
+ ]);
125
+ var NON_IDENTIFIER_PLACEHOLDER_PATTERN = /^(?:\[[A-Z_]+\]|<[^>]+>)$/;
126
+ var RESERVED_DIMENSION_NAMES = new Set([
127
+ ...Object.values(BaseDimensions),
128
+ ...Object.values(CommandDimensions),
129
+ ...Object.values(ShipDimensions),
130
+ ...Object.values(ProjectDimensions),
131
+ ...Object.values(ErrorDimensions),
132
+ ...Object.values(AuthDimensions),
133
+ ...Object.values(SkillsDimensions),
134
+ ...Object.values(PackagerDimensions),
135
+ ...Object.values(ScopeDimensions)
136
+ ]);
137
+ var CURATED_DIMENSIONS = new Set([
138
+ BaseDimensions.ApplicationName,
139
+ BaseDimensions.ProductVersion,
140
+ BaseDimensions.InstallationId,
141
+ BaseDimensions.CloudUserId,
142
+ BaseDimensions.CloudTenantId,
143
+ BaseDimensions.CloudOrganizationId,
144
+ BaseDimensions.IsInternalUser,
145
+ BaseDimensions.Environment,
146
+ BaseDimensions.BaseUrl,
147
+ BaseDimensions.Region,
148
+ BaseDimensions.Agent,
149
+ BaseDimensions.AgentVersion,
150
+ BaseDimensions.ToolVersion,
151
+ BaseDimensions.ExecutionContext,
152
+ BaseDimensions.CiProvider,
153
+ BaseDimensions.SessionIdSource,
154
+ BaseDimensions.SessionId,
155
+ BaseDimensions.HostApp,
156
+ BaseDimensions.HostAppSource,
157
+ ...Object.values(CommandDimensions),
158
+ ...Object.values(ShipDimensions),
159
+ ...Object.values(ProjectDimensions)
160
+ ]);
161
+ function lowercaseIdDimensionValues(properties) {
162
+ let changed = false;
163
+ const result = {
164
+ ...properties
165
+ };
166
+ for (const key of Object.keys(result)) {
167
+ const value = result[key];
168
+ if (!ID_DIMENSIONS.has(key) || typeof value !== "string" || NON_IDENTIFIER_PLACEHOLDER_PATTERN.test(value)) {
169
+ continue;
170
+ }
171
+ const lowered = value.toLowerCase();
172
+ if (lowered !== value) {
173
+ result[key] = lowered;
174
+ changed = true;
175
+ }
176
+ }
177
+ return changed ? result : properties;
178
+ }
179
+
180
+ // ../common/src/singleton.ts
181
+ var PREFIX = "@uipath/common/";
182
+ var _g = globalThis;
183
+ function singleton(name) {
184
+ if (typeof name !== "string") {
185
+ throw new TypeError("singleton() takes a string name. A class name is not stable across bundles.");
186
+ }
187
+ const key = Symbol.for(PREFIX + name);
188
+ return {
189
+ get(fallback) {
190
+ return _g[key] ?? fallback;
191
+ },
192
+ set(value) {
193
+ _g[key] = value;
194
+ },
195
+ clear() {
196
+ delete _g[key];
197
+ },
198
+ getOrInit(factory, guard) {
199
+ const existing = _g[key];
200
+ if (existing != null && typeof existing === "object") {
201
+ if (!guard || guard(existing)) {
202
+ return existing;
203
+ }
204
+ }
205
+ const instance = factory();
206
+ _g[key] = instance;
207
+ return instance;
208
+ }
209
+ };
210
+ }
211
+
212
+ // ../common/src/telemetry/telemetry-config.ts
213
+ function isTelemetryDisabled() {
214
+ const value = process.env.UIPATH_TELEMETRY_DISABLED;
215
+ return value === "1" || value === "true";
216
+ }
217
+ function isProjectTelemetryDisabled() {
218
+ return isTelemetryDisabled() || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "1" || process.env.UIPATH_PROJECT_TELEMETRY_DISABLED === "true";
219
+ }
220
+
221
+ // ../common/src/telemetry/global-telemetry-properties.ts
222
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
223
+ function getGlobalTelemetryProperties() {
224
+ return telemetryPropsSlot.get();
225
+ }
226
+
227
+ // ../common/src/sdk-user-agent.ts
228
+ var USER_AGENT_HEADER = "User-Agent";
229
+ var AGENT_PROPERTY = BaseDimensions.Agent;
230
+ var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
231
+ function userAgentPatchKey(userAgent) {
232
+ return Symbol.for(`@uipath/common/sdk-user-agent/${userAgent}`);
233
+ }
234
+ function splitUserAgentTokens(value) {
235
+ return value?.trim().split(/\s+/).filter(Boolean) ?? [];
236
+ }
237
+ function appendUserAgentToken(value, userAgent) {
238
+ const tokens = splitUserAgentTokens(value);
239
+ const seen = new Set(tokens);
240
+ for (const token of splitUserAgentTokens(userAgent)) {
241
+ if (!seen.has(token)) {
242
+ tokens.push(token);
243
+ seen.add(token);
244
+ }
245
+ }
246
+ return tokens.join(" ");
247
+ }
248
+ function getEffectiveUserAgent(userAgent) {
249
+ return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
250
+ }
251
+ function getHeaderName(headers, headerName) {
252
+ return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
253
+ }
254
+ function getSdkUserAgentToken(pkg) {
255
+ const packageName = pkg.name.replace(/^@uipath\//, "");
256
+ return getEffectiveUserAgent(`${packageName}/${pkg.version}`);
257
+ }
258
+ function addSdkUserAgentHeader(headers, userAgent) {
259
+ const result = { ...headers ?? {} };
260
+ const headerName = getHeaderName(result, USER_AGENT_HEADER);
261
+ result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
262
+ return result;
263
+ }
264
+ function asHeaderRecord(headers) {
265
+ return typeof headers === "object" && headers !== null ? { ...headers } : {};
266
+ }
267
+ function withForwardedHeadersInitOverride(initOverrides, forward) {
268
+ return async (requestContext) => {
269
+ const initWithHeaders = {
270
+ ...requestContext.init,
271
+ headers: forward(asHeaderRecord(requestContext.init.headers))
272
+ };
273
+ const override = typeof initOverrides === "function" ? await initOverrides({
274
+ ...requestContext,
275
+ init: initWithHeaders
276
+ }) : initOverrides;
277
+ return {
278
+ ...override ?? {},
279
+ headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
280
+ };
281
+ };
282
+ }
283
+ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
284
+ const prototype = BaseApiClass.prototype;
285
+ if (prototype[patchKey]) {
286
+ return;
287
+ }
288
+ if (typeof prototype.request !== "function") {
289
+ throw new Error("Generated BaseAPI request function not found.");
290
+ }
291
+ const originalRequest = prototype.request;
292
+ prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
293
+ return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
294
+ };
295
+ Object.defineProperty(prototype, patchKey, {
296
+ value: true
297
+ });
298
+ }
299
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
300
+ installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
301
+ }
302
+
8
303
  // ../auth/src/catch-error.ts
9
304
  function isPromiseLike(value) {
10
305
  return value !== null && typeof value === "object" && typeof value.then === "function";
@@ -75,15 +370,15 @@ var parseJWT = (token) => {
75
370
  throw new Error(`Failed to parse JWT: ${error instanceof Error ? error.message : "Unknown error"}`);
76
371
  }
77
372
  };
78
- var assertIssuerMatchesAuthority = (token, authority) => {
373
+ var assertTokenIssuer = (token, expectedIssuer) => {
374
+ const stripTrailingSlash = (s) => s.replace(/\/+$/, "");
375
+ const expected = stripTrailingSlash(expectedIssuer);
79
376
  let payload;
80
377
  try {
81
378
  payload = parseJWT(token);
82
379
  } catch (error) {
83
- throw new InvalidIssuerError(`${authority.replace(/\/+$/, "")}/identity_`, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
380
+ throw new InvalidIssuerError(expected, `<unparseable: ${error instanceof Error ? error.message : "unknown error"}>`);
84
381
  }
85
- const stripTrailingSlash = (s) => s.replace(/\/+$/, "");
86
- const expected = `${stripTrailingSlash(authority)}/identity_`;
87
382
  const actual = typeof payload.iss === "string" ? stripTrailingSlash(payload.iss) : undefined;
88
383
  if (actual !== expected) {
89
384
  throw new InvalidIssuerError(expected, payload.iss);
@@ -248,6 +543,19 @@ function normalizeAuthProfileName(profile) {
248
543
  }
249
544
  return profile;
250
545
  }
546
+ function getAuthProfileState(create) {
547
+ const scopedState = profileStorage.getStore();
548
+ if (scopedState !== undefined) {
549
+ return scopedState;
550
+ }
551
+ const existing = globalSlot[ACTIVE_AUTH_PROFILE_KEY];
552
+ if (existing !== undefined || !create) {
553
+ return existing;
554
+ }
555
+ const created = {};
556
+ globalSlot[ACTIVE_AUTH_PROFILE_KEY] = created;
557
+ return created;
558
+ }
251
559
  function getActiveAuthProfile() {
252
560
  const scopedState = profileStorage.getStore();
253
561
  if (scopedState !== undefined) {
@@ -281,7 +589,7 @@ class InvalidBaseUrlError extends Error {
281
589
  super(`Invalid base URL: "${url}"
282
590
  ` + `Reason: ${reason}
283
591
 
284
- ` + `Expected format: an https:// URL (or bare host — https:// is assumed), e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), or your Automation Suite host (https://<your-host>).
592
+ ` + `Expected format: an https:// URL (or bare host — https:// is assumed), e.g. https://cloud.uipath.com (commercial), https://govcloud.uipath.us (Public Sector), your Automation Suite host (https://<your-host>), or a standalone Orchestrator's identity URL (https://<your-host>/identity).
285
593
  ` + `You can specify the URL via:
286
594
  ` + ` • --authority flag
287
595
  ` + ` • UIPATH_URL environment variable
@@ -292,13 +600,17 @@ class InvalidBaseUrlError extends Error {
292
600
  }
293
601
  }
294
602
  var DEFAULT_SCOPES = ["openid", "profile", "offline_access"];
295
- var normalizeAndValidateBaseUrl = (rawUrl) => {
603
+ var normalizeAndValidateBaseUrl = (rawUrl) => parseAuthority(rawUrl).baseUrl;
604
+ var GATEWAY_IDENTITY_PATH = "/identity_";
605
+ var STANDALONE_IDENTITY_PATH = "/identity";
606
+ var resolveAuthority = (rawUrl) => {
607
+ const { baseUrl, pathname } = parseAuthority(rawUrl);
608
+ const standalone = pathname === STANDALONE_IDENTITY_PATH;
609
+ const identityPath = standalone ? STANDALONE_IDENTITY_PATH : GATEWAY_IDENTITY_PATH;
610
+ return { baseUrl, issuer: `${baseUrl}${identityPath}`, standalone };
611
+ };
612
+ var parseAuthority = (rawUrl) => {
296
613
  let baseUrl = rawUrl;
297
- if (baseUrl.endsWith("/identity_/")) {
298
- baseUrl = baseUrl.slice(0, -11);
299
- } else if (baseUrl.endsWith("/identity_")) {
300
- baseUrl = baseUrl.slice(0, -10);
301
- }
302
614
  while (baseUrl.endsWith("/")) {
303
615
  baseUrl = baseUrl.slice(0, -1);
304
616
  }
@@ -316,7 +628,10 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
316
628
  if (url.protocol !== "https:") {
317
629
  throw new InvalidBaseUrlError(baseUrl, `Authority must use https:// scheme, got ${url.protocol}//. OIDC token exchange requires TLS end-to-end.`);
318
630
  }
319
- return url.pathname.length > 1 ? url.origin : baseUrl;
631
+ return {
632
+ baseUrl: url.pathname.length > 1 ? url.origin : baseUrl,
633
+ pathname: url.pathname
634
+ };
320
635
  };
321
636
  var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
322
637
  const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
@@ -342,7 +657,7 @@ var resolveConfigAsync = async ({
342
657
  if (!baseUrl) {
343
658
  baseUrl = DEFAULT_BASE_URL;
344
659
  }
345
- baseUrl = normalizeAndValidateBaseUrl(baseUrl);
660
+ const authority = resolveAuthority(baseUrl);
346
661
  const clientId = customClientId || DEFAULT_CLIENT_ID;
347
662
  const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && (Boolean(customClientSecret) || Boolean(customClientAssertion));
348
663
  const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
@@ -350,9 +665,11 @@ var resolveConfigAsync = async ({
350
665
  clientId,
351
666
  clientSecret: customClientSecret,
352
667
  scopes,
353
- baseUrl,
354
- authorizationEndpoint: `${baseUrl}/identity_/connect/authorize`,
355
- tokenEndpoint: `${baseUrl}/identity_/connect/token`
668
+ baseUrl: authority.baseUrl,
669
+ issuer: authority.issuer,
670
+ standalone: authority.standalone,
671
+ authorizationEndpoint: `${authority.issuer}/connect/authorize`,
672
+ tokenEndpoint: `${authority.issuer}/connect/token`
356
673
  };
357
674
  };
358
675
 
@@ -503,6 +820,85 @@ function shouldSurface(state, nowMs) {
503
820
  return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
504
821
  }
505
822
 
823
+ // ../auth/src/resolvedSession.ts
824
+ var AMBIGUOUS = "ambiguous";
825
+ var READER_KEY = Symbol.for("@uipath/auth/ResolvedSessionReader");
826
+ var PENDING_TENANT_KEY = Symbol.for("@uipath/auth/PendingCommandTenant");
827
+ var PENDING_TARGET_ELSEWHERE_KEY = Symbol.for("@uipath/auth/PendingCallTargetElsewhere");
828
+ var isSessionSlot = (value) => value === AMBIGUOUS || typeof value === "object" && value !== null && ("session" in value);
829
+ var sameLogin = (a, b) => a.profile === b.profile && a.organization === b.organization && a.tenant === b.tenant;
830
+ function currentSlot(state) {
831
+ return isSessionSlot(state?.session) ? state.session : undefined;
832
+ }
833
+ function recordResolvedSession(session) {
834
+ const state = getAuthProfileState(true);
835
+ if (state === undefined) {
836
+ return;
837
+ }
838
+ const current = currentSlot(state);
839
+ if (current === AMBIGUOUS) {
840
+ return;
841
+ }
842
+ state.session = current === undefined || sameLogin(current.session, session) ? { session } : AMBIGUOUS;
843
+ }
844
+ function getResolvedSession() {
845
+ const slot = currentSlot(getAuthProfileState(false));
846
+ return slot === undefined || slot === AMBIGUOUS ? undefined : { ...slot.session };
847
+ }
848
+ function setCommandTenant(tenant) {
849
+ const name = tenant === "" ? undefined : tenant;
850
+ const state = getAuthProfileState(name !== undefined);
851
+ if (state === undefined) {
852
+ return;
853
+ }
854
+ if (name === undefined) {
855
+ delete state.commandTenant;
856
+ return;
857
+ }
858
+ state.commandTenant = name;
859
+ }
860
+ function getCommandTenant() {
861
+ return getAuthProfileState(false)?.commandTenant;
862
+ }
863
+ function setCallTargetElsewhere(elsewhere) {
864
+ const state = getAuthProfileState(elsewhere);
865
+ if (state === undefined) {
866
+ return;
867
+ }
868
+ if (elsewhere) {
869
+ state.callTargetElsewhere = true;
870
+ return;
871
+ }
872
+ delete state.callTargetElsewhere;
873
+ }
874
+ function readForFailure() {
875
+ if (getAuthProfileState(false)?.callTargetElsewhere === true) {
876
+ return;
877
+ }
878
+ const session = getResolvedSession();
879
+ const commandTenant = getCommandTenant();
880
+ return session && commandTenant ? { ...session, commandTenant } : session;
881
+ }
882
+ var globalSlot3 = globalThis;
883
+ if (globalSlot3[READER_KEY] === undefined) {
884
+ globalSlot3[READER_KEY] = {
885
+ __brand: "ResolvedSessionReader",
886
+ read: readForFailure,
887
+ setCommandTenant,
888
+ setCallTargetElsewhere
889
+ };
890
+ const pending = globalSlot3[PENDING_TENANT_KEY];
891
+ const elsewhere = globalSlot3[PENDING_TARGET_ELSEWHERE_KEY] === true;
892
+ delete globalSlot3[PENDING_TENANT_KEY];
893
+ delete globalSlot3[PENDING_TARGET_ELSEWHERE_KEY];
894
+ if (typeof pending === "string") {
895
+ setCommandTenant(pending);
896
+ }
897
+ if (elsewhere) {
898
+ setCallTargetElsewhere(true);
899
+ }
900
+ }
901
+
506
902
  // ../auth/src/robotClientFallback.ts
507
903
  var DEFAULT_TIMEOUT_MS = 1000;
508
904
  var CLOSE_TIMEOUT_MS = 500;
@@ -647,6 +1043,14 @@ var tryRobotClientFallback = async (options = {}) => {
647
1043
  };
648
1044
 
649
1045
  // ../auth/src/tenantSelection.ts
1046
+ var findTenantByName = (tenants, name) => {
1047
+ const exact = tenants.find((tenant) => tenant.name === name);
1048
+ if (exact)
1049
+ return exact;
1050
+ const wanted = name.toLowerCase();
1051
+ const matches = tenants.filter((tenant) => tenant.name.toLowerCase() === wanted);
1052
+ return matches.length === 1 ? matches[0] : undefined;
1053
+ };
650
1054
  var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
651
1055
  var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
652
1056
  var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
@@ -697,6 +1101,7 @@ var refreshAccessToken = async ({
697
1101
  refreshToken,
698
1102
  tokenEndpoint,
699
1103
  clientId,
1104
+ expectedIssuer,
700
1105
  expectedAuthority
701
1106
  }) => {
702
1107
  const tokenParams = new URLSearchParams({
@@ -723,8 +1128,9 @@ var refreshAccessToken = async ({
723
1128
  if (typeof newAccessToken !== "string" || typeof newRefreshToken !== "string") {
724
1129
  throw new Error("Token refresh response is missing access_token or refresh_token");
725
1130
  }
726
- if (expectedAuthority) {
727
- assertIssuerMatchesAuthority(newAccessToken, expectedAuthority);
1131
+ const issuer = expectedIssuer || (expectedAuthority ? resolveAuthority(expectedAuthority).issuer : "");
1132
+ if (issuer) {
1133
+ assertTokenIssuer(newAccessToken, issuer);
728
1134
  }
729
1135
  return { accessToken: newAccessToken, refreshToken: newRefreshToken };
730
1136
  };
@@ -938,8 +1344,26 @@ var saveEnvFileAsync = async ({
938
1344
  var defaultRobotTenantIdCache = new Map;
939
1345
  var ROBOT_TENANT_LOOKUP_TIMEOUT_MS = 5000;
940
1346
  var getLoginStatusAsync = async (options = {}) => {
941
- return getLoginStatusWithDeps(options);
1347
+ const status = await getLoginStatusWithDeps(options);
1348
+ recordLoginSession(status, options);
1349
+ return status;
942
1350
  };
1351
+ function profileOf(status, { envFilePath, envFileIsProfile }) {
1352
+ if (envFilePath !== undefined && !envFileIsProfile || status.source !== "saved-login" /* SavedLogin */) {
1353
+ return;
1354
+ }
1355
+ return getActiveAuthProfile() ?? DEFAULT_AUTH_PROFILE;
1356
+ }
1357
+ function recordLoginSession(status, options = {}) {
1358
+ if (status.loginStatus !== "Logged in") {
1359
+ return;
1360
+ }
1361
+ recordResolvedSession({
1362
+ profile: profileOf(status, options),
1363
+ organization: status.organizationName ?? status.organizationId,
1364
+ tenant: status.tenantName ?? status.tenantId
1365
+ });
1366
+ }
943
1367
  var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
944
1368
  const {
945
1369
  resolveEnvFilePath = resolveEnvFilePathAsync,
@@ -957,8 +1381,8 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
957
1381
  clearBreaker = clearRefreshBreaker
958
1382
  } = deps;
959
1383
  const robotDeps = {
960
- fetchTenantsAndOrgs,
961
- cache: robotTenantIdCache,
1384
+ fetchTenantsAndOrgs: options.offline ? () => Promise.reject(new Error("offline: no tenant lookup")) : fetchTenantsAndOrgs,
1385
+ cache: options.offline ? new Map : robotTenantIdCache,
962
1386
  lookupTimeoutMs: robotTenantLookupTimeoutMs
963
1387
  };
964
1388
  if (isRobotAuthEnforced()) {
@@ -997,7 +1421,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
997
1421
  lockReleaseFailed: false
998
1422
  };
999
1423
  const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
1000
- if (expiration && expiration <= outerThreshold && refreshToken) {
1424
+ if (options.offline !== true && expiration && expiration <= outerThreshold && refreshToken) {
1001
1425
  const refreshed = await attemptRefresh({
1002
1426
  absolutePath,
1003
1427
  credentials,
@@ -1020,7 +1444,7 @@ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
1020
1444
  }
1021
1445
  tokens = refreshed.tokens;
1022
1446
  }
1023
- return buildFileStatus(tokens, credentials, globalHint);
1447
+ return buildFileStatus(tokens, credentials, globalHint, absolutePath);
1024
1448
  };
1025
1449
  async function resolveRobotEnforcedStatus(robotFallback, deps) {
1026
1450
  if (isEnvAuthEnabled()) {
@@ -1097,7 +1521,7 @@ async function attemptRefresh(ctx) {
1097
1521
  const outcome = await runRefreshLocked({
1098
1522
  absolutePath: ctx.absolutePath,
1099
1523
  refreshToken: ctx.refreshToken,
1100
- customAuthority: ctx.credentials.UIPATH_URL,
1524
+ customAuthority: sessionAuthority(ctx.credentials.UIPATH_URL, ctx.accessToken),
1101
1525
  ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
1102
1526
  loadEnvFile: ctx.loadEnvFile,
1103
1527
  saveEnvFile: ctx.saveEnvFile,
@@ -1139,7 +1563,7 @@ async function attemptRefresh(ctx) {
1139
1563
  }
1140
1564
  };
1141
1565
  }
1142
- async function buildFileStatus(tokens, credentials, globalHint) {
1566
+ async function buildFileStatus(tokens, credentials, globalHint, absolutePath) {
1143
1567
  const result = {
1144
1568
  loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
1145
1569
  accessToken: tokens.accessToken,
@@ -1149,8 +1573,10 @@ async function buildFileStatus(tokens, credentials, globalHint) {
1149
1573
  organizationId: credentials.UIPATH_ORGANIZATION_ID,
1150
1574
  tenantName: credentials.UIPATH_TENANT_NAME,
1151
1575
  tenantId: credentials.UIPATH_TENANT_ID,
1576
+ issuer: savedSessionIssuer(credentials.UIPATH_URL, tokens.accessToken),
1152
1577
  expiration: tokens.expiration,
1153
1578
  source: "saved-login" /* SavedLogin */,
1579
+ envFilePath: absolutePath,
1154
1580
  ...identityFields(tokens.accessToken, credentials),
1155
1581
  ...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
1156
1582
  ...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
@@ -1221,9 +1647,7 @@ async function lookupRobotTenantId(target, deps) {
1221
1647
  }
1222
1648
  const rows = data?.tenants;
1223
1649
  const tenants = Array.isArray(rows) ? rows.filter((tenant) => typeof tenant?.id === "string" && typeof tenant?.name === "string") : [];
1224
- const wantedName = decodePathSegment(tenantName);
1225
- const wanted = wantedName.toLowerCase();
1226
- const match = tenants.find((tenant) => tenant.name === wantedName) ?? tenants.find((tenant) => tenant.name.toLowerCase() === wanted);
1650
+ const match = findTenantByName(tenants, decodePathSegment(tenantName));
1227
1651
  if (!match) {
1228
1652
  const names = tenants.map((tenant) => tenant.name).join(", ");
1229
1653
  return {
@@ -1330,6 +1754,21 @@ async function lockAcquireFailureStatus(ctx, error) {
1330
1754
  }
1331
1755
  };
1332
1756
  }
1757
+ var savedSessionIssuer = (url, accessToken) => {
1758
+ if (!url || !accessToken)
1759
+ return;
1760
+ const [, payload] = catchError(() => parseJWT(accessToken));
1761
+ const iss = payload?.iss;
1762
+ if (typeof iss !== "string")
1763
+ return;
1764
+ const [, minted] = catchError(() => resolveAuthority(iss));
1765
+ const [, session] = catchError(() => resolveAuthority(url));
1766
+ if (!minted || !session || minted.baseUrl !== session.baseUrl) {
1767
+ return;
1768
+ }
1769
+ return minted.issuer === iss.replace(/\/+$/, "") ? minted.issuer : undefined;
1770
+ };
1771
+ var sessionAuthority = (url, accessToken) => savedSessionIssuer(url, accessToken) ?? url;
1333
1772
  async function runRefreshLocked(inputs) {
1334
1773
  const {
1335
1774
  absolutePath,
@@ -1383,7 +1822,7 @@ async function runRefreshLocked(inputs) {
1383
1822
  refreshToken: tokenForIdP,
1384
1823
  tokenEndpoint: config.tokenEndpoint,
1385
1824
  clientId: config.clientId,
1386
- expectedAuthority: customAuthority
1825
+ expectedIssuer: config.issuer
1387
1826
  });
1388
1827
  refreshedAccess = refreshed.accessToken;
1389
1828
  refreshedRefresh = refreshed.refreshToken;
@@ -1526,6 +1965,6 @@ var TENANT_SELECTION_CODES = new Set([
1526
1965
  TENANT_SELECTION_REQUIRED_CODE,
1527
1966
  INVALID_TENANT_CODE
1528
1967
  ]);
1529
- export { resolveSessionIdentity, getAuthContext };
1968
+ export { BaseDimensions, CommandDimensions, ProjectDimensions, GUID_KEY_DIMENSIONS, ShipDimensions, ErrorDimensions, SkillsDimensions, lowercaseIdDimensionValues, singleton, getGlobalTelemetryProperties, isProjectTelemetryDisabled, getSdkUserAgentToken, addSdkUserAgentHeader, installSdkUserAgentHeader, resolveSessionIdentity, readTokenScopes, getAuthContext };
1530
1969
 
1531
- //# debugId=AA87E0E976E3245664756E2164756E21
1970
+ //# debugId=0735565A115BDDB164756E2164756E21