@uipath/integrationservice-sdk 1.195.0 → 1.197.0-preview.59

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.
Files changed (2) hide show
  1. package/dist/index.js +548 -282
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -19164,6 +19164,9 @@ function singleton(ctorOrName) {
19164
19164
  };
19165
19165
  }
19166
19166
 
19167
+ // ../common/src/telemetry/global-telemetry-properties.ts
19168
+ var telemetryPropsSlot = singleton("TelemetryDefaultProps");
19169
+
19167
19170
  // ../common/src/sdk-user-agent.ts
19168
19171
  var USER_AGENT_HEADER = "User-Agent";
19169
19172
  var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
@@ -19187,8 +19190,8 @@ function appendUserAgentToken(value, userAgent) {
19187
19190
  function getEffectiveUserAgent(userAgent) {
19188
19191
  return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent);
19189
19192
  }
19190
- function isHeadersLike(headers) {
19191
- return typeof headers === "object" && headers !== null && "get" in headers && typeof headers.get === "function" && "set" in headers && typeof headers.set === "function";
19193
+ function getHeaderName(headers, headerName) {
19194
+ return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase());
19192
19195
  }
19193
19196
  function getSdkUserAgentToken(pkg) {
19194
19197
  const packageName = pkg.name.replace(/^@uipath\//, "");
@@ -19196,59 +19199,31 @@ function getSdkUserAgentToken(pkg) {
19196
19199
  }
19197
19200
  function addSdkUserAgentHeader(headers, userAgent) {
19198
19201
  const result = { ...headers ?? {} };
19199
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
19200
- const headerName = Object.keys(result).find((key) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
19201
- if (headerName) {
19202
- result[headerName] = appendUserAgentToken(result[headerName], effectiveUserAgent);
19203
- } else {
19204
- result[USER_AGENT_HEADER] = effectiveUserAgent;
19205
- }
19202
+ const headerName = getHeaderName(result, USER_AGENT_HEADER);
19203
+ result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent));
19206
19204
  return result;
19207
19205
  }
19208
- function withSdkUserAgentHeader(headers, userAgent) {
19209
- const effectiveUserAgent = getEffectiveUserAgent(userAgent);
19210
- if (isHeadersLike(headers)) {
19211
- headers.set(USER_AGENT_HEADER, appendUserAgentToken(headers.get(USER_AGENT_HEADER), effectiveUserAgent));
19212
- return headers;
19213
- }
19214
- if (Array.isArray(headers)) {
19215
- const result = headers.map((entry) => {
19216
- const [key, value] = entry;
19217
- return [key, value];
19218
- });
19219
- const headerIndex = result.findIndex(([key]) => key.toLowerCase() === USER_AGENT_HEADER.toLowerCase());
19220
- if (headerIndex >= 0) {
19221
- const [key, value] = result[headerIndex];
19222
- result[headerIndex] = [
19223
- key,
19224
- appendUserAgentToken(value, effectiveUserAgent)
19225
- ];
19226
- } else {
19227
- result.push([USER_AGENT_HEADER, effectiveUserAgent]);
19228
- }
19229
- return result;
19230
- }
19231
- return addSdkUserAgentHeader(typeof headers === "object" && headers !== null ? { ...headers } : {}, effectiveUserAgent);
19206
+ function asHeaderRecord(headers) {
19207
+ return typeof headers === "object" && headers !== null ? { ...headers } : {};
19232
19208
  }
19233
- function withUserAgentInitOverride(initOverrides, userAgent) {
19209
+ function withForwardedHeadersInitOverride(initOverrides, forward) {
19234
19210
  return async (requestContext) => {
19235
- const initWithUserAgent = {
19211
+ const initWithHeaders = {
19236
19212
  ...requestContext.init,
19237
- headers: withSdkUserAgentHeader(requestContext.init.headers, userAgent)
19213
+ headers: forward(asHeaderRecord(requestContext.init.headers))
19238
19214
  };
19239
19215
  const override = typeof initOverrides === "function" ? await initOverrides({
19240
19216
  ...requestContext,
19241
- init: initWithUserAgent
19217
+ init: initWithHeaders
19242
19218
  }) : initOverrides;
19243
19219
  return {
19244
19220
  ...override ?? {},
19245
- headers: withSdkUserAgentHeader(override?.headers ?? initWithUserAgent.headers, userAgent)
19221
+ headers: forward(asHeaderRecord(override?.headers ?? initWithHeaders.headers))
19246
19222
  };
19247
19223
  };
19248
19224
  }
19249
- function installSdkUserAgentHeader(BaseApiClass, userAgent) {
19225
+ function installRequestHeaderForwarding(BaseApiClass, patchKey, forward) {
19250
19226
  const prototype = BaseApiClass.prototype;
19251
- const patchKey = userAgentPatchKey(userAgent);
19252
19227
  if (prototype[patchKey]) {
19253
19228
  return;
19254
19229
  }
@@ -19256,13 +19231,16 @@ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
19256
19231
  throw new Error("Generated BaseAPI request function not found.");
19257
19232
  }
19258
19233
  const originalRequest = prototype.request;
19259
- prototype.request = function requestWithUserAgent(context, initOverrides) {
19260
- return originalRequest.call(this, context, withUserAgentInitOverride(initOverrides, userAgent));
19234
+ prototype.request = function requestWithForwardedHeaders(context, initOverrides) {
19235
+ return originalRequest.call(this, context, withForwardedHeadersInitOverride(initOverrides, forward));
19261
19236
  };
19262
19237
  Object.defineProperty(prototype, patchKey, {
19263
19238
  value: true
19264
19239
  });
19265
19240
  }
19241
+ function installSdkUserAgentHeader(BaseApiClass, userAgent) {
19242
+ installRequestHeaderForwarding(BaseApiClass, userAgentPatchKey(userAgent), (headers) => addSdkUserAgentHeader(headers, userAgent));
19243
+ }
19266
19244
 
19267
19245
  // generated/connections/src/runtime.ts
19268
19246
  var BASE_PATH = "https://alpha.uipath.com/entity/Azure/connections_".replace(/\/+$/, "");
@@ -19833,7 +19811,7 @@ class TextApiResponse2 {
19833
19811
  var package_default = {
19834
19812
  name: "@uipath/integrationservice-sdk",
19835
19813
  license: "MIT",
19836
- version: "1.195.0",
19814
+ version: "1.197.0-preview.59",
19837
19815
  repository: {
19838
19816
  type: "git",
19839
19817
  url: "https://github.com/UiPath/cli.git",
@@ -19860,7 +19838,7 @@ var package_default = {
19860
19838
  "dist"
19861
19839
  ],
19862
19840
  scripts: {
19863
- build: "bun build ./src/index.ts --outdir dist --format esm --target node && tsc -p tsconfig.build.json --noCheck",
19841
+ build: "bun build ./src/index.ts --outdir dist --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
19864
19842
  generate: "bun run src/scripts/generate-sdk.ts",
19865
19843
  lint: "biome check .",
19866
19844
  test: "vitest run",
@@ -38854,6 +38832,12 @@ var normalizeAndValidateBaseUrl = (rawUrl) => {
38854
38832
  }
38855
38833
  return url.pathname.length > 1 ? url.origin : baseUrl;
38856
38834
  };
38835
+ var resolveScopes = (isExternalAppAuth, customScopes, fileScopes) => {
38836
+ const requestedScopes = customScopes?.length ? customScopes : fileScopes ?? [];
38837
+ if (isExternalAppAuth)
38838
+ return requestedScopes;
38839
+ return [...new Set([...DEFAULT_SCOPES, ...requestedScopes])];
38840
+ };
38857
38841
  var resolveConfigAsync = async ({
38858
38842
  customAuthority,
38859
38843
  customClientId,
@@ -38884,7 +38868,7 @@ var resolveConfigAsync = async ({
38884
38868
  clientSecret = fileAuth.clientSecret;
38885
38869
  }
38886
38870
  const isExternalAppAuth = clientId !== DEFAULT_CLIENT_ID && Boolean(clientSecret);
38887
- const scopes = customScopes && customScopes.length > 0 ? customScopes : fileAuth.scopes && fileAuth.scopes.length > 0 ? fileAuth.scopes : isExternalAppAuth ? [] : DEFAULT_SCOPES;
38871
+ const scopes = resolveScopes(isExternalAppAuth, customScopes, fileAuth.scopes);
38888
38872
  return {
38889
38873
  clientId,
38890
38874
  clientSecret,
@@ -38899,6 +38883,76 @@ var resolveConfigAsync = async ({
38899
38883
  init_constants();
38900
38884
  // ../auth/src/loginStatus.ts
38901
38885
  init_src();
38886
+
38887
+ // ../auth/src/authProfile.ts
38888
+ init_src();
38889
+ init_constants();
38890
+ var DEFAULT_AUTH_PROFILE = "default";
38891
+ var PROFILE_DIR = "profiles";
38892
+ var PROFILE_NAME_RE = /^[A-Za-z0-9._-]+$/;
38893
+ var ACTIVE_AUTH_PROFILE_KEY = Symbol.for("@uipath/auth/ActiveAuthProfile");
38894
+ var AUTH_PROFILE_STORAGE_KEY = Symbol.for("@uipath/auth/ProfileStorage");
38895
+ var globalSlot2 = globalThis;
38896
+ function isAuthProfileStorage(value) {
38897
+ return value !== null && typeof value === "object" && "getStore" in value && "run" in value;
38898
+ }
38899
+ function createProfileStorage() {
38900
+ const [error, mod] = catchError(() => __require("node:async_hooks"));
38901
+ if (error || typeof mod?.AsyncLocalStorage !== "function") {
38902
+ return {
38903
+ getStore: () => {
38904
+ return;
38905
+ },
38906
+ run: (_store, fn) => fn()
38907
+ };
38908
+ }
38909
+ return new mod.AsyncLocalStorage;
38910
+ }
38911
+ function getProfileStorage() {
38912
+ const existing = globalSlot2[AUTH_PROFILE_STORAGE_KEY];
38913
+ if (isAuthProfileStorage(existing)) {
38914
+ return existing;
38915
+ }
38916
+ const storage = createProfileStorage();
38917
+ globalSlot2[AUTH_PROFILE_STORAGE_KEY] = storage;
38918
+ return storage;
38919
+ }
38920
+ var profileStorage = getProfileStorage();
38921
+
38922
+ class AuthProfileValidationError extends Error {
38923
+ constructor(message) {
38924
+ super(message);
38925
+ this.name = "AuthProfileValidationError";
38926
+ }
38927
+ }
38928
+ function normalizeAuthProfileName(profile) {
38929
+ if (profile === undefined || profile === DEFAULT_AUTH_PROFILE) {
38930
+ return;
38931
+ }
38932
+ if (profile.length === 0 || profile === "." || profile === ".." || !PROFILE_NAME_RE.test(profile)) {
38933
+ throw new AuthProfileValidationError(`Invalid profile name "${profile}". Profile names may contain only letters, numbers, '.', '_', and '-'.`);
38934
+ }
38935
+ return profile;
38936
+ }
38937
+ function getActiveAuthProfile() {
38938
+ const scopedState = profileStorage.getStore();
38939
+ if (scopedState !== undefined) {
38940
+ return scopedState.profile;
38941
+ }
38942
+ return globalSlot2[ACTIVE_AUTH_PROFILE_KEY]?.profile;
38943
+ }
38944
+ function resolveAuthProfileFilePath(profile) {
38945
+ const normalized = normalizeAuthProfileName(profile);
38946
+ if (normalized === undefined) {
38947
+ throw new AuthProfileValidationError(`"${DEFAULT_AUTH_PROFILE}" is the built-in profile and does not have a profile file path.`);
38948
+ }
38949
+ const fs7 = getFileSystem();
38950
+ return fs7.path.join(fs7.env.homedir(), UIPATH_HOME_DIR, PROFILE_DIR, normalized, AUTH_FILENAME);
38951
+ }
38952
+ function getActiveAuthProfileFilePath() {
38953
+ const profile = getActiveAuthProfile();
38954
+ return profile ? resolveAuthProfileFilePath(profile) : undefined;
38955
+ }
38902
38956
  // ../auth/src/utils/jwt.ts
38903
38957
  class InvalidIssuerError extends Error {
38904
38958
  expected;
@@ -39027,23 +39081,74 @@ var readAuthFromEnv = () => {
39027
39081
  organizationId,
39028
39082
  tenantName,
39029
39083
  tenantId,
39030
- expiration
39084
+ expiration,
39085
+ source: "env" /* Env */
39031
39086
  };
39032
39087
  };
39033
39088
 
39089
+ // ../auth/src/refreshCircuitBreaker.ts
39090
+ init_src();
39091
+ var BREAKER_SUFFIX = ".refresh-state";
39092
+ var BACKOFF_BASE_MS = 60000;
39093
+ var BACKOFF_CAP_MS = 60 * 60 * 1000;
39094
+ var SURFACE_WINDOW_MS = 60 * 60 * 1000;
39095
+ async function refreshTokenFingerprint(refreshToken) {
39096
+ const bytes = new TextEncoder().encode(refreshToken);
39097
+ if (globalThis.crypto?.subtle) {
39098
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
39099
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("").slice(0, 16);
39100
+ }
39101
+ const { createHash } = await import("node:crypto");
39102
+ return createHash("sha256").update(refreshToken).digest("hex").slice(0, 16);
39103
+ }
39104
+ function breakerPathFor(authPath) {
39105
+ return `${authPath}${BREAKER_SUFFIX}`;
39106
+ }
39107
+ async function loadRefreshBreaker(authPath) {
39108
+ const fs7 = getFileSystem();
39109
+ try {
39110
+ const content = await fs7.readFile(breakerPathFor(authPath), "utf-8");
39111
+ if (!content)
39112
+ return {};
39113
+ const parsed = JSON.parse(content);
39114
+ return parsed && typeof parsed === "object" ? parsed : {};
39115
+ } catch {
39116
+ return {};
39117
+ }
39118
+ }
39119
+ async function saveRefreshBreaker(authPath, state) {
39120
+ try {
39121
+ const fs7 = getFileSystem();
39122
+ const path3 = breakerPathFor(authPath);
39123
+ await fs7.mkdir(fs7.path.dirname(path3));
39124
+ const tempPath = `${path3}.tmp`;
39125
+ await fs7.writeFile(tempPath, JSON.stringify(state));
39126
+ await fs7.rename(tempPath, path3);
39127
+ } catch {}
39128
+ }
39129
+ async function clearRefreshBreaker(authPath) {
39130
+ const fs7 = getFileSystem();
39131
+ const path3 = breakerPathFor(authPath);
39132
+ try {
39133
+ if (await fs7.exists(path3)) {
39134
+ await fs7.rm(path3);
39135
+ }
39136
+ } catch {}
39137
+ }
39138
+ function nextBackoffMs(attempts) {
39139
+ const shift = Math.max(0, attempts - 1);
39140
+ return Math.min(BACKOFF_BASE_MS * 2 ** shift, BACKOFF_CAP_MS);
39141
+ }
39142
+ function shouldSurface(state, nowMs) {
39143
+ if (state.lastSurfacedAtMs === undefined)
39144
+ return true;
39145
+ return nowMs - state.lastSurfacedAtMs >= SURFACE_WINDOW_MS;
39146
+ }
39147
+
39034
39148
  // ../auth/src/robotClientFallback.ts
39035
39149
  init_src();
39036
39150
  var DEFAULT_TIMEOUT_MS = 1000;
39037
39151
  var CLOSE_TIMEOUT_MS = 500;
39038
- var NOTICE_SENTINEL = Symbol.for("@uipath/auth/robotFallbackNoticePrinted");
39039
- var printNoticeOnce = () => {
39040
- const slot = globalThis;
39041
- if (slot[NOTICE_SENTINEL])
39042
- return;
39043
- slot[NOTICE_SENTINEL] = true;
39044
- catchError(() => process.stderr.write(`Using UiPath Robot credentials. Run 'uip login' for a dedicated session.
39045
- `));
39046
- };
39047
39152
  var ROBOT_USER_SERVICES_PIPE = "UiPathUserServices";
39048
39153
  var ROBOT_USER_SERVICES_ALTERNATE_PIPE = `${ROBOT_USER_SERVICES_PIPE}Alternate`;
39049
39154
  var PIPE_NAME_MAX_LENGTH = 103;
@@ -39088,11 +39193,11 @@ var parseResourceUrl = (url) => {
39088
39193
  if (error || !parsed)
39089
39194
  return;
39090
39195
  const segments = parsed.pathname.split("/").filter(Boolean);
39091
- const organizationName = segments[0];
39092
- const tenantName = segments[1];
39093
- if (!organizationName || !tenantName)
39094
- return;
39095
- return { baseUrl: parsed.origin, organizationName, tenantName };
39196
+ return {
39197
+ baseUrl: parsed.origin,
39198
+ organizationName: segments[0],
39199
+ tenantName: segments[1]
39200
+ };
39096
39201
  };
39097
39202
  var defaultLoadModule = async () => {
39098
39203
  const [error, mod] = await catchError(() => Promise.resolve().then(() => __toESM(require_dist(), 1)));
@@ -39143,6 +39248,7 @@ var tryRobotClientFallback = async (options = {}) => {
39143
39248
  }
39144
39249
  let organizationIdFromToken;
39145
39250
  let tenantIdFromToken;
39251
+ let issuerFromToken;
39146
39252
  const [jwtError, claims] = catchError(() => parseJWT(accessToken));
39147
39253
  if (!jwtError && claims) {
39148
39254
  const rawOrgId = claims.prtId ?? claims.organizationId ?? claims.prt_id;
@@ -39153,15 +39259,19 @@ var tryRobotClientFallback = async (options = {}) => {
39153
39259
  if (typeof tenantClaim === "string" && tenantClaim.length > 0) {
39154
39260
  tenantIdFromToken = tenantClaim;
39155
39261
  }
39262
+ const issClaim = claims.iss;
39263
+ if (typeof issClaim === "string" && issClaim.length > 0) {
39264
+ issuerFromToken = issClaim;
39265
+ }
39156
39266
  }
39157
- printNoticeOnce();
39158
39267
  return {
39159
39268
  accessToken,
39160
39269
  baseUrl: parsedUrl.baseUrl,
39161
39270
  organizationName: parsedUrl.organizationName,
39162
39271
  organizationId: organizationIdFromToken ?? parsedUrl.organizationName,
39163
39272
  tenantName: parsedUrl.tenantName,
39164
- tenantId: tenantIdFromToken
39273
+ tenantId: tenantIdFromToken,
39274
+ issuer: issuerFromToken
39165
39275
  };
39166
39276
  } catch {
39167
39277
  return;
@@ -39263,7 +39373,7 @@ var probeAsync = async (fs7, candidate) => {
39263
39373
  };
39264
39374
  }
39265
39375
  };
39266
- var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME) => {
39376
+ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
39267
39377
  const fs7 = getFileSystem();
39268
39378
  if (fs7.path.isAbsolute(envFilePath)) {
39269
39379
  const probe2 = await probeAsync(fs7, envFilePath);
@@ -39274,7 +39384,7 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME) =>
39274
39384
  ...probe2.unusable ? { unusable: probe2.unusable } : {}
39275
39385
  };
39276
39386
  }
39277
- const cwd = fs7.env.cwd();
39387
+ const cwd = opts?.cwd ?? fs7.env.cwd();
39278
39388
  let searchDir = cwd;
39279
39389
  while (true) {
39280
39390
  const candidate = fs7.path.join(searchDir, envFilePath);
@@ -39304,8 +39414,8 @@ var resolveEnvFileLocationAsync = async (envFilePath = DEFAULT_ENV_FILENAME) =>
39304
39414
  ...probe.unusable ? { unusable: probe.unusable } : {}
39305
39415
  };
39306
39416
  };
39307
- var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME) => {
39308
- const location = await resolveEnvFileLocationAsync(envFilePath);
39417
+ var resolveEnvFilePathAsync = async (envFilePath = DEFAULT_ENV_FILENAME, opts) => {
39418
+ const location = await resolveEnvFileLocationAsync(envFilePath, opts);
39309
39419
  if (location.exists) {
39310
39420
  return { absolutePath: location.absolutePath };
39311
39421
  }
@@ -39378,18 +39488,327 @@ var saveEnvFileAsync = async ({
39378
39488
  };
39379
39489
 
39380
39490
  // ../auth/src/loginStatus.ts
39381
- function normalizeTokenRefreshFailure() {
39382
- return "stored refresh token is invalid or expired";
39491
+ var getLoginStatusAsync = async (options = {}) => {
39492
+ return getLoginStatusWithDeps(options);
39493
+ };
39494
+ var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
39495
+ const {
39496
+ resolveEnvFilePath = resolveEnvFilePathAsync,
39497
+ loadEnvFile = loadEnvFileAsync,
39498
+ saveEnvFile = saveEnvFileAsync,
39499
+ getFs = getFileSystem,
39500
+ refreshToken: refreshTokenFn = refreshAccessToken,
39501
+ resolveConfig = resolveConfigAsync,
39502
+ robotFallback = tryRobotClientFallback,
39503
+ loadBreaker = loadRefreshBreaker,
39504
+ saveBreaker = saveRefreshBreaker,
39505
+ clearBreaker = clearRefreshBreaker
39506
+ } = deps;
39507
+ if (isRobotAuthEnforced()) {
39508
+ return resolveRobotEnforcedStatus(robotFallback);
39509
+ }
39510
+ if (isEnvAuthEnabled()) {
39511
+ return readAuthFromEnv();
39512
+ }
39513
+ const activeProfile = getActiveAuthProfile();
39514
+ const activeProfileFilePath = getActiveAuthProfileFilePath();
39515
+ const usingActiveProfile = activeProfile !== undefined && (options.envFilePath === undefined || options.envFilePath === activeProfileFilePath);
39516
+ const envFilePath = options.envFilePath ?? activeProfileFilePath ?? DEFAULT_ENV_FILENAME;
39517
+ const { ensureTokenValidityMinutes } = options;
39518
+ const { absolutePath } = await resolveEnvFilePath(envFilePath);
39519
+ if (absolutePath === undefined) {
39520
+ if (usingActiveProfile) {
39521
+ return {
39522
+ loginStatus: "Not logged in",
39523
+ hint: `No credentials found for profile "${activeProfile}". Run 'uip login --profile ${activeProfile}' to authenticate this profile.`
39524
+ };
39525
+ }
39526
+ return resolveBorrowedRobotStatus(robotFallback);
39527
+ }
39528
+ const loaded = await loadFileCredentials(loadEnvFile, absolutePath);
39529
+ if ("status" in loaded) {
39530
+ return loaded.status;
39531
+ }
39532
+ const { credentials } = loaded;
39533
+ const globalHint = () => usingActiveProfile ? Promise.resolve(undefined) : getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath);
39534
+ const expiration = getTokenExpiration(credentials.UIPATH_ACCESS_TOKEN);
39535
+ const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
39536
+ let tokens = {
39537
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
39538
+ refreshToken: credentials.UIPATH_REFRESH_TOKEN,
39539
+ expiration,
39540
+ lockReleaseFailed: false
39541
+ };
39542
+ const refreshToken = credentials.UIPATH_REFRESH_TOKEN;
39543
+ if (expiration && expiration <= outerThreshold && refreshToken) {
39544
+ const refreshed = await attemptRefresh({
39545
+ absolutePath,
39546
+ credentials,
39547
+ accessToken: credentials.UIPATH_ACCESS_TOKEN,
39548
+ refreshToken,
39549
+ expiration,
39550
+ ensureTokenValidityMinutes,
39551
+ getFs,
39552
+ loadEnvFile,
39553
+ saveEnvFile,
39554
+ refreshFn: refreshTokenFn,
39555
+ resolveConfig,
39556
+ loadBreaker,
39557
+ saveBreaker,
39558
+ clearBreaker,
39559
+ globalHint
39560
+ });
39561
+ if (refreshed.kind === "terminal") {
39562
+ return refreshed.status;
39563
+ }
39564
+ tokens = refreshed.tokens;
39565
+ }
39566
+ return buildFileStatus(tokens, credentials, globalHint);
39567
+ };
39568
+ async function resolveRobotEnforcedStatus(robotFallback) {
39569
+ if (isEnvAuthEnabled()) {
39570
+ throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
39571
+ }
39572
+ const robotCreds = await robotFallback({ force: true });
39573
+ if (!robotCreds) {
39574
+ return {
39575
+ loginStatus: "Not logged in",
39576
+ hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
39577
+ };
39578
+ }
39579
+ return buildRobotStatus(robotCreds);
39383
39580
  }
39384
- function normalizeTokenRefreshUnavailableFailure() {
39385
- return "token refresh failed before authentication completed";
39581
+ async function resolveBorrowedRobotStatus(robotFallback) {
39582
+ const robotCreds = await robotFallback();
39583
+ return robotCreds ? buildRobotStatus(robotCreds) : { loginStatus: "Not logged in" };
39386
39584
  }
39387
- function errorMessage(error) {
39388
- return error instanceof Error ? error.message : String(error);
39585
+ async function loadFileCredentials(loadEnvFile, absolutePath) {
39586
+ let credentials;
39587
+ try {
39588
+ credentials = await loadEnvFile({ envPath: absolutePath });
39589
+ } catch (error) {
39590
+ if (isFileNotFoundError(error)) {
39591
+ return { status: { loginStatus: "Not logged in" } };
39592
+ }
39593
+ throw error;
39594
+ }
39595
+ if (!credentials.UIPATH_ACCESS_TOKEN) {
39596
+ return { status: { loginStatus: "Not logged in" } };
39597
+ }
39598
+ return { credentials };
39599
+ }
39600
+ async function getGlobalCredsHint(getFs, loadEnvFile, absolutePath, envFilePath) {
39601
+ const fs7 = getFs();
39602
+ const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
39603
+ if (absolutePath === globalPath)
39604
+ return;
39605
+ if (!await fs7.exists(globalPath))
39606
+ return;
39607
+ try {
39608
+ const globalCreds = await loadEnvFile({ envPath: globalPath });
39609
+ if (!globalCreds.UIPATH_ACCESS_TOKEN)
39610
+ return;
39611
+ const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
39612
+ if (globalExp && globalExp <= new Date)
39613
+ return;
39614
+ return `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
39615
+ } catch {
39616
+ return;
39617
+ }
39389
39618
  }
39390
39619
  function computeExpirationThreshold(ensureTokenValidityMinutes) {
39391
39620
  return new Date(Date.now() + (ensureTokenValidityMinutes ?? 0) * 60 * 1000);
39392
39621
  }
39622
+ async function attemptRefresh(ctx) {
39623
+ const shortCircuit = await circuitBreakerShortCircuit(ctx);
39624
+ if (shortCircuit) {
39625
+ return { kind: "terminal", status: shortCircuit };
39626
+ }
39627
+ let release;
39628
+ try {
39629
+ release = await ctx.getFs().acquireLock(ctx.absolutePath);
39630
+ } catch (error) {
39631
+ return {
39632
+ kind: "terminal",
39633
+ status: await lockAcquireFailureStatus(ctx, error)
39634
+ };
39635
+ }
39636
+ let lockedFailure;
39637
+ let lockReleaseFailed = false;
39638
+ let success;
39639
+ try {
39640
+ const outcome = await runRefreshLocked({
39641
+ absolutePath: ctx.absolutePath,
39642
+ refreshToken: ctx.refreshToken,
39643
+ customAuthority: ctx.credentials.UIPATH_URL,
39644
+ ensureTokenValidityMinutes: ctx.ensureTokenValidityMinutes,
39645
+ loadEnvFile: ctx.loadEnvFile,
39646
+ saveEnvFile: ctx.saveEnvFile,
39647
+ refreshFn: ctx.refreshFn,
39648
+ resolveConfig: ctx.resolveConfig,
39649
+ loadBreaker: ctx.loadBreaker,
39650
+ saveBreaker: ctx.saveBreaker,
39651
+ clearBreaker: ctx.clearBreaker
39652
+ });
39653
+ if (outcome.kind === "fail") {
39654
+ lockedFailure = outcome.status;
39655
+ } else {
39656
+ success = outcome;
39657
+ }
39658
+ } finally {
39659
+ try {
39660
+ await release();
39661
+ } catch {
39662
+ lockReleaseFailed = true;
39663
+ }
39664
+ }
39665
+ if (lockedFailure) {
39666
+ const globalHint = await ctx.globalHint();
39667
+ const base = globalHint ? { ...lockedFailure, loginStatus: "Expired", hint: globalHint } : lockedFailure;
39668
+ return {
39669
+ kind: "terminal",
39670
+ status: lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base
39671
+ };
39672
+ }
39673
+ return {
39674
+ kind: "refreshed",
39675
+ tokens: {
39676
+ accessToken: success?.accessToken,
39677
+ refreshToken: success?.refreshToken,
39678
+ expiration: success?.expiration,
39679
+ tokenRefresh: success?.tokenRefresh,
39680
+ persistenceWarning: success?.persistenceWarning,
39681
+ lockReleaseFailed
39682
+ }
39683
+ };
39684
+ }
39685
+ async function buildFileStatus(tokens, credentials, globalHint) {
39686
+ const result = {
39687
+ loginStatus: tokens.expiration && tokens.expiration <= new Date ? "Expired" : "Logged in",
39688
+ accessToken: tokens.accessToken,
39689
+ refreshToken: tokens.refreshToken,
39690
+ baseUrl: credentials.UIPATH_URL,
39691
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
39692
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
39693
+ tenantName: credentials.UIPATH_TENANT_NAME,
39694
+ tenantId: credentials.UIPATH_TENANT_ID,
39695
+ expiration: tokens.expiration,
39696
+ source: "file" /* File */,
39697
+ ...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
39698
+ ...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
39699
+ ...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
39700
+ };
39701
+ if (result.loginStatus === "Expired") {
39702
+ const hint = await globalHint();
39703
+ if (hint) {
39704
+ result.hint = hint;
39705
+ }
39706
+ }
39707
+ return result;
39708
+ }
39709
+ function buildRobotStatus(robotCreds) {
39710
+ return {
39711
+ loginStatus: "Logged in",
39712
+ accessToken: robotCreds.accessToken,
39713
+ baseUrl: robotCreds.baseUrl,
39714
+ organizationName: robotCreds.organizationName,
39715
+ organizationId: robotCreds.organizationId,
39716
+ tenantName: robotCreds.tenantName,
39717
+ tenantId: robotCreds.tenantId,
39718
+ issuer: robotCreds.issuer,
39719
+ expiration: getTokenExpiration(robotCreds.accessToken),
39720
+ source: "robot" /* Robot */
39721
+ };
39722
+ }
39723
+ var isFileNotFoundError = (error) => {
39724
+ if (!(error instanceof Object))
39725
+ return false;
39726
+ return error.code === "ENOENT";
39727
+ };
39728
+ async function circuitBreakerShortCircuit(ctx) {
39729
+ const {
39730
+ absolutePath,
39731
+ refreshToken,
39732
+ accessToken,
39733
+ credentials,
39734
+ expiration,
39735
+ loadBreaker,
39736
+ saveBreaker,
39737
+ clearBreaker
39738
+ } = ctx;
39739
+ const fingerprint = await refreshTokenFingerprint(refreshToken);
39740
+ const breaker = await loadBreaker(absolutePath).catch(() => ({}));
39741
+ if (breaker.deadTokenFp && breaker.deadTokenFp !== fingerprint) {
39742
+ await clearBreaker(absolutePath);
39743
+ breaker.deadTokenFp = undefined;
39744
+ }
39745
+ const nowMs = Date.now();
39746
+ const tokenIsDead = breaker.deadTokenFp === fingerprint;
39747
+ const inBackoff = breaker.backoffUntilMs !== undefined && nowMs < breaker.backoffUntilMs;
39748
+ if (!tokenIsDead && !inBackoff)
39749
+ return;
39750
+ const globalHint = await ctx.globalHint();
39751
+ const suppressed = !shouldSurface(breaker, nowMs);
39752
+ if (!suppressed) {
39753
+ await saveBreaker(absolutePath, {
39754
+ ...breaker,
39755
+ lastSurfacedAtMs: nowMs
39756
+ });
39757
+ }
39758
+ const deadHint = "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired. In a non-interactive context, authenticate with: uip login --client-id <id> --client-secret <secret> -t <tenant>.";
39759
+ const backoffHint = "Token refresh is temporarily backed off after a recent network error and will retry automatically once the backoff window elapses.";
39760
+ return {
39761
+ loginStatus: globalHint ? "Expired" : "Refresh Failed",
39762
+ ...globalHint ? {
39763
+ accessToken,
39764
+ refreshToken,
39765
+ baseUrl: credentials.UIPATH_URL,
39766
+ organizationName: credentials.UIPATH_ORGANIZATION_NAME,
39767
+ organizationId: credentials.UIPATH_ORGANIZATION_ID,
39768
+ tenantName: credentials.UIPATH_TENANT_NAME,
39769
+ tenantId: credentials.UIPATH_TENANT_ID,
39770
+ expiration,
39771
+ source: "file" /* File */
39772
+ } : {},
39773
+ hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
39774
+ refreshCircuitOpen: true,
39775
+ refreshTelemetrySuppressed: suppressed,
39776
+ tokenRefresh: { attempted: false, success: false }
39777
+ };
39778
+ }
39779
+ async function lockAcquireFailureStatus(ctx, error) {
39780
+ const msg = errorMessage(error);
39781
+ const globalHint = await ctx.globalHint();
39782
+ if (globalHint) {
39783
+ return {
39784
+ loginStatus: "Expired",
39785
+ accessToken: ctx.accessToken,
39786
+ refreshToken: ctx.refreshToken,
39787
+ baseUrl: ctx.credentials.UIPATH_URL,
39788
+ organizationName: ctx.credentials.UIPATH_ORGANIZATION_NAME,
39789
+ organizationId: ctx.credentials.UIPATH_ORGANIZATION_ID,
39790
+ tenantName: ctx.credentials.UIPATH_TENANT_NAME,
39791
+ tenantId: ctx.credentials.UIPATH_TENANT_ID,
39792
+ expiration: ctx.expiration,
39793
+ source: "file" /* File */,
39794
+ hint: globalHint,
39795
+ tokenRefresh: {
39796
+ attempted: false,
39797
+ success: false,
39798
+ errorMessage: `lock acquisition failed: ${msg}`
39799
+ }
39800
+ };
39801
+ }
39802
+ return {
39803
+ loginStatus: "Refresh Failed",
39804
+ hint: "Could not acquire the auth-file lock — too many concurrent `uip` processes, or a permission issue on the auth directory. Retry, or run 'uip login' to re-authenticate.",
39805
+ tokenRefresh: {
39806
+ attempted: false,
39807
+ success: false,
39808
+ errorMessage: `lock acquisition failed: ${msg}`
39809
+ }
39810
+ };
39811
+ }
39393
39812
  async function runRefreshLocked(inputs) {
39394
39813
  const {
39395
39814
  absolutePath,
@@ -39399,7 +39818,10 @@ async function runRefreshLocked(inputs) {
39399
39818
  loadEnvFile,
39400
39819
  saveEnvFile,
39401
39820
  refreshFn,
39402
- resolveConfig
39821
+ resolveConfig,
39822
+ loadBreaker,
39823
+ saveBreaker,
39824
+ clearBreaker
39403
39825
  } = inputs;
39404
39826
  const expirationThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
39405
39827
  let fresh;
@@ -39422,6 +39844,7 @@ async function runRefreshLocked(inputs) {
39422
39844
  const freshAccess = fresh.UIPATH_ACCESS_TOKEN;
39423
39845
  const freshExp = freshAccess ? getTokenExpiration(freshAccess) : undefined;
39424
39846
  if (freshAccess && freshExp && freshExp > expirationThreshold) {
39847
+ await clearBreaker(absolutePath);
39425
39848
  return {
39426
39849
  kind: "ok",
39427
39850
  accessToken: freshAccess,
@@ -39445,8 +39868,21 @@ async function runRefreshLocked(inputs) {
39445
39868
  refreshedRefresh = refreshed.refreshToken;
39446
39869
  } catch (error) {
39447
39870
  const isOAuthFailure = isTokenRefreshOAuthFailure(error);
39448
- const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
39871
+ const hint = isOAuthFailure ? "Run 'uip login' to re-authenticate — the stored refresh token is invalid or expired. In a non-interactive context, authenticate with: uip login --client-id <id> --client-secret <secret> -t <tenant>." : "Token refresh failed. Check your network connection, then retry or run 'uip login' to re-authenticate.";
39449
39872
  const message = isOAuthFailure ? normalizeTokenRefreshFailure() : normalizeTokenRefreshUnavailableFailure();
39873
+ const fp = await refreshTokenFingerprint(tokenForIdP);
39874
+ if (isOAuthFailure) {
39875
+ await saveBreaker(absolutePath, { deadTokenFp: fp });
39876
+ } else {
39877
+ const prior = await loadBreaker(absolutePath).catch(() => ({}));
39878
+ const attempts = (prior.attempts ?? 0) + 1;
39879
+ await saveBreaker(absolutePath, {
39880
+ ...prior,
39881
+ deadTokenFp: undefined,
39882
+ attempts,
39883
+ backoffUntilMs: Date.now() + nextBackoffMs(attempts)
39884
+ });
39885
+ }
39450
39886
  return {
39451
39887
  kind: "fail",
39452
39888
  status: {
@@ -39475,6 +39911,7 @@ async function runRefreshLocked(inputs) {
39475
39911
  }
39476
39912
  };
39477
39913
  }
39914
+ await clearBreaker(absolutePath);
39478
39915
  try {
39479
39916
  await saveEnvFile({
39480
39917
  envPath: absolutePath,
@@ -39507,215 +39944,21 @@ async function runRefreshLocked(inputs) {
39507
39944
  };
39508
39945
  }
39509
39946
  }
39510
- var getLoginStatusWithDeps = async (options = {}, deps = {}) => {
39511
- const {
39512
- resolveEnvFilePath = resolveEnvFilePathAsync,
39513
- loadEnvFile = loadEnvFileAsync,
39514
- saveEnvFile = saveEnvFileAsync,
39515
- getFs = getFileSystem,
39516
- refreshToken: refreshTokenFn = refreshAccessToken,
39517
- resolveConfig = resolveConfigAsync,
39518
- robotFallback = tryRobotClientFallback
39519
- } = deps;
39520
- if (isRobotAuthEnforced()) {
39521
- if (isEnvAuthEnabled()) {
39522
- throw new EnvAuthConfigError(`${ENV_AUTH_ENABLE_VAR}=true and ${ENFORCE_ROBOT_AUTH_VAR}=true ` + `are mutually exclusive. Unset one of them and re-run.`);
39523
- }
39524
- const robotCreds = await robotFallback({ force: true });
39525
- if (!robotCreds) {
39526
- return {
39527
- loginStatus: "Not logged in",
39528
- hint: `${ENFORCE_ROBOT_AUTH_VAR}=true but the UiPath Robot ` + `session is unavailable. Start and sign in to the Assistant, ` + `or unset ${ENFORCE_ROBOT_AUTH_VAR} to fall back to file or ` + `env-var authentication.`
39529
- };
39530
- }
39531
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
39532
- return {
39533
- loginStatus: "Logged in",
39534
- accessToken: robotCreds.accessToken,
39535
- baseUrl: robotCreds.baseUrl,
39536
- organizationName: robotCreds.organizationName,
39537
- organizationId: robotCreds.organizationId,
39538
- tenantName: robotCreds.tenantName,
39539
- tenantId: robotCreds.tenantId,
39540
- expiration: expiration2,
39541
- source: "robot" /* Robot */
39542
- };
39543
- }
39544
- if (isEnvAuthEnabled()) {
39545
- return readAuthFromEnv();
39546
- }
39547
- const { envFilePath = DEFAULT_ENV_FILENAME, ensureTokenValidityMinutes } = options;
39548
- const { absolutePath } = await resolveEnvFilePath(envFilePath);
39549
- if (absolutePath === undefined) {
39550
- const robotCreds = await robotFallback();
39551
- if (robotCreds) {
39552
- const expiration2 = getTokenExpiration(robotCreds.accessToken);
39553
- const status = {
39554
- loginStatus: "Logged in",
39555
- accessToken: robotCreds.accessToken,
39556
- baseUrl: robotCreds.baseUrl,
39557
- organizationName: robotCreds.organizationName,
39558
- organizationId: robotCreds.organizationId,
39559
- tenantName: robotCreds.tenantName,
39560
- tenantId: robotCreds.tenantId,
39561
- expiration: expiration2,
39562
- source: "robot" /* Robot */
39563
- };
39564
- return status;
39565
- }
39566
- return { loginStatus: "Not logged in" };
39567
- }
39568
- let credentials;
39569
- try {
39570
- credentials = await loadEnvFile({ envPath: absolutePath });
39571
- } catch (error) {
39572
- if (isFileNotFoundError(error)) {
39573
- return { loginStatus: "Not logged in" };
39574
- }
39575
- throw error;
39576
- }
39577
- if (!credentials.UIPATH_ACCESS_TOKEN) {
39578
- return { loginStatus: "Not logged in" };
39579
- }
39580
- let accessToken = credentials.UIPATH_ACCESS_TOKEN;
39581
- let refreshToken = credentials.UIPATH_REFRESH_TOKEN;
39582
- let expiration = getTokenExpiration(accessToken);
39583
- let persistenceWarning;
39584
- let lockReleaseFailed = false;
39585
- let tokenRefresh;
39586
- const outerThreshold = computeExpirationThreshold(ensureTokenValidityMinutes);
39587
- const tryGlobalCredsHint = async () => {
39588
- const fs7 = getFs();
39589
- const globalPath = fs7.path.join(fs7.env.homedir(), envFilePath);
39590
- if (absolutePath === globalPath)
39591
- return;
39592
- if (!await fs7.exists(globalPath))
39593
- return;
39594
- try {
39595
- const globalCreds = await loadEnvFile({ envPath: globalPath });
39596
- if (!globalCreds.UIPATH_ACCESS_TOKEN)
39597
- return;
39598
- const globalExp = getTokenExpiration(globalCreds.UIPATH_ACCESS_TOKEN);
39599
- if (globalExp && globalExp <= new Date)
39600
- return;
39601
- return `Local credentials file at ${absolutePath} has expired credentials. Valid credentials exist in ${globalPath}. Remove the local file or run 'uip login' to re-authenticate.`;
39602
- } catch {
39603
- return;
39604
- }
39605
- };
39606
- if (expiration && expiration <= outerThreshold && refreshToken) {
39607
- let release;
39608
- try {
39609
- release = await getFs().acquireLock(absolutePath);
39610
- } catch (error) {
39611
- const msg = errorMessage(error);
39612
- const globalHint = await tryGlobalCredsHint();
39613
- if (globalHint) {
39614
- return {
39615
- loginStatus: "Expired",
39616
- accessToken,
39617
- refreshToken,
39618
- baseUrl: credentials.UIPATH_URL,
39619
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
39620
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
39621
- tenantName: credentials.UIPATH_TENANT_NAME,
39622
- tenantId: credentials.UIPATH_TENANT_ID,
39623
- expiration,
39624
- source: "file" /* File */,
39625
- hint: globalHint,
39626
- tokenRefresh: {
39627
- attempted: false,
39628
- success: false,
39629
- errorMessage: `lock acquisition failed: ${msg}`
39630
- }
39631
- };
39632
- }
39633
- return {
39634
- loginStatus: "Refresh Failed",
39635
- hint: "Could not acquire the auth-file lock — too many concurrent `uip` processes, or a permission issue on the auth directory. Retry, or run 'uip login' to re-authenticate.",
39636
- tokenRefresh: {
39637
- attempted: false,
39638
- success: false,
39639
- errorMessage: `lock acquisition failed: ${msg}`
39640
- }
39641
- };
39642
- }
39643
- let lockedFailure;
39644
- try {
39645
- const outcome = await runRefreshLocked({
39646
- absolutePath,
39647
- refreshToken,
39648
- customAuthority: credentials.UIPATH_URL,
39649
- ensureTokenValidityMinutes,
39650
- loadEnvFile,
39651
- saveEnvFile,
39652
- refreshFn: refreshTokenFn,
39653
- resolveConfig
39654
- });
39655
- if (outcome.kind === "fail") {
39656
- lockedFailure = outcome.status;
39657
- } else {
39658
- accessToken = outcome.accessToken;
39659
- refreshToken = outcome.refreshToken;
39660
- expiration = outcome.expiration;
39661
- tokenRefresh = outcome.tokenRefresh;
39662
- if (outcome.persistenceWarning) {
39663
- persistenceWarning = outcome.persistenceWarning;
39664
- }
39665
- }
39666
- } finally {
39667
- try {
39668
- await release();
39669
- } catch {
39670
- lockReleaseFailed = true;
39671
- }
39672
- }
39673
- if (lockedFailure) {
39674
- const globalHint = await tryGlobalCredsHint();
39675
- const base = globalHint ? {
39676
- ...lockedFailure,
39677
- loginStatus: "Expired",
39678
- hint: globalHint
39679
- } : lockedFailure;
39680
- return lockReleaseFailed ? { ...base, lockReleaseFailed: true } : base;
39681
- }
39682
- }
39683
- const result = {
39684
- loginStatus: expiration && expiration <= new Date ? "Expired" : "Logged in",
39685
- accessToken,
39686
- refreshToken,
39687
- baseUrl: credentials.UIPATH_URL,
39688
- organizationName: credentials.UIPATH_ORGANIZATION_NAME,
39689
- organizationId: credentials.UIPATH_ORGANIZATION_ID,
39690
- tenantName: credentials.UIPATH_TENANT_NAME,
39691
- tenantId: credentials.UIPATH_TENANT_ID,
39692
- expiration,
39693
- source: "file" /* File */,
39694
- ...persistenceWarning ? { hint: persistenceWarning, persistenceFailed: true } : {},
39695
- ...lockReleaseFailed ? { lockReleaseFailed: true } : {},
39696
- ...tokenRefresh ? { tokenRefresh } : {}
39697
- };
39698
- if (result.loginStatus === "Expired") {
39699
- const globalHint = await tryGlobalCredsHint();
39700
- if (globalHint) {
39701
- result.hint = globalHint;
39702
- }
39703
- }
39704
- return result;
39705
- };
39706
- var isFileNotFoundError = (error) => {
39707
- if (!(error instanceof Object))
39708
- return false;
39709
- return error.code === "ENOENT";
39710
- };
39711
- var getLoginStatusAsync = async (options = {}) => {
39712
- return getLoginStatusWithDeps(options);
39713
- };
39947
+ function normalizeTokenRefreshFailure() {
39948
+ return "stored refresh token is invalid or expired";
39949
+ }
39950
+ function normalizeTokenRefreshUnavailableFailure() {
39951
+ return "token refresh failed before authentication completed";
39952
+ }
39953
+ function errorMessage(error) {
39954
+ return error instanceof Error ? error.message : String(error);
39955
+ }
39714
39956
 
39715
39957
  // ../auth/src/authContext.ts
39716
39958
  var getAuthContext = async (options = {}) => {
39717
39959
  const status = await getLoginStatusAsync({
39718
- ensureTokenValidityMinutes: options.ensureTokenValidityMinutes
39960
+ ensureTokenValidityMinutes: options.ensureTokenValidityMinutes,
39961
+ envFilePath: options.envFilePath
39719
39962
  });
39720
39963
  if (status.loginStatus !== "Logged in" || !status.baseUrl || !status.accessToken) {
39721
39964
  throw new Error(status.hint ? `Not logged in. ${status.hint}` : "Not logged in. Run 'uip login' first.");
@@ -39744,6 +39987,14 @@ var getAuthContext = async (options = {}) => {
39744
39987
  };
39745
39988
  // ../auth/src/interactive.ts
39746
39989
  init_src();
39990
+
39991
+ // ../auth/src/selectTenant.ts
39992
+ var TENANT_SELECTION_REQUIRED_CODE = "TENANT_SELECTION_REQUIRED";
39993
+ var INVALID_TENANT_CODE = "INVALID_TENANT";
39994
+ var TENANT_SELECTION_CODES = new Set([
39995
+ TENANT_SELECTION_REQUIRED_CODE,
39996
+ INVALID_TENANT_CODE
39997
+ ]);
39747
39998
  // ../auth/src/logout.ts
39748
39999
  init_src();
39749
40000
 
@@ -39970,10 +40221,12 @@ function folderOverride(folderKey) {
39970
40221
  var MANAGED_HTTP_CONNECTOR_KEY = "uipath-uipath-http";
39971
40222
  var MANAGED_HTTP_CONNECTOR_VERSION = "1.4.50";
39972
40223
  function buildActivityEssentialConfiguration(instanceParameters, methodInfo, savedFilterTrees = null, customFieldsRequestDetails = null) {
40224
+ const operation = methodInfo.operation.toLowerCase();
40225
+ const savedJitInputFieldId = computeSavedJitInputFieldId(operation, methodInfo.parameters, instanceParameters.objectName);
39973
40226
  const essentialConfiguration = {
39974
40227
  instanceParameters,
39975
40228
  objectName: instanceParameters.objectName,
39976
- operation: methodInfo.operation.toLowerCase(),
40229
+ operation,
39977
40230
  httpMethod: methodInfo.method,
39978
40231
  path: methodInfo.path,
39979
40232
  packageVersion: "1.0.0",
@@ -39983,10 +40236,21 @@ function buildActivityEssentialConfiguration(instanceParameters, methodInfo, sav
39983
40236
  unifiedTypesCompatible: true,
39984
40237
  ...savedFilterTrees !== null && Object.keys(savedFilterTrees).length > 0 && {
39985
40238
  savedFilterTrees
39986
- }
40239
+ },
40240
+ ...savedJitInputFieldId !== undefined && { savedJitInputFieldId }
39987
40241
  };
39988
40242
  return { essentialConfiguration };
39989
40243
  }
40244
+ var JIT_INPUT_OPERATIONS = new Set(["create", "update", "replace"]);
40245
+ function computeSavedJitInputFieldId(operation, parameters, objectName) {
40246
+ if (!JIT_INPUT_OPERATIONS.has(operation))
40247
+ return;
40248
+ if (typeof objectName !== "string" || objectName.length === 0)
40249
+ return;
40250
+ if (!(parameters ?? []).some((p) => p.type === "body"))
40251
+ return;
40252
+ return `in_${objectName}`;
40253
+ }
39990
40254
  function buildManagedHttpEssentialConfiguration() {
39991
40255
  const essentialConfiguration = {
39992
40256
  connectorVersion: MANAGED_HTTP_CONNECTOR_VERSION,
@@ -40423,7 +40687,7 @@ class CeqlHelper {
40423
40687
  if (fieldType.isSame(ClrTypeMock.Enum)) {
40424
40688
  value = CeqlHelper._getCeqlValueFromEnumValue(value);
40425
40689
  }
40426
- const expression = value == null ? StringExtensions.empty : value.isLiteral ? value.value : "${" + String(value.value) + "}";
40690
+ const expression = value == null ? StringExtensions.empty : value.isLiteral ? value.value : `\${${String(value.value)}}`;
40427
40691
  const valueExpression = CeqlHelper._isStringValue(fieldType) ? `'${String(expression).replace(/'/g, "''")}'` : `${expression}`;
40428
40692
  return CeqlHelper._composeSingleValueExpression(field, op, valueExpression);
40429
40693
  }
@@ -42658,3 +42922,5 @@ export {
42658
42922
  AccessTokenResponseFromJSONTyped,
42659
42923
  AccessTokenResponseFromJSON
42660
42924
  };
42925
+
42926
+ //# debugId=6A2EE5FC74326D7A64756E2164756E21
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/integrationservice-sdk",
3
3
  "license": "MIT",
4
- "version": "1.195.0",
4
+ "version": "1.197.0-preview.59",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/UiPath/cli.git",
@@ -27,5 +27,5 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
- "gitHead": "eecf5713cd579b15783c770d1923e44e730271ea"
30
+ "gitHead": "df0e2b8140cced13f463b487214927c82bc0f85b"
31
31
  }