@uipath/auth 1.199.0 → 1.201.0-preview.115

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.
@@ -2,6 +2,7 @@ import { getFileSystem } from "@uipath/filesystem";
2
2
  import { resolveConfigAsync } from "./config";
3
3
  import { clearRefreshBreaker, loadRefreshBreaker, saveRefreshBreaker } from "./refreshCircuitBreaker";
4
4
  import { tryRobotClientFallback } from "./robotClientFallback";
5
+ import { type SessionIdentity } from "./sessionIdentity";
5
6
  import { refreshAccessToken } from "./tokenRefresh";
6
7
  import { loadEnvFileAsync, resolveEnvFilePathAsync, saveEnvFileAsync } from "./utils/envFile";
7
8
  /**
@@ -10,10 +11,15 @@ import { loadEnvFileAsync, resolveEnvFilePathAsync, saveEnvFileAsync } from "./u
10
11
  * refresh was tried and could not complete with a usable token.
11
12
  */
12
13
  export type LoginStatusValue = "Logged in" | "Not logged in" | "Expired" | "Refresh Failed";
13
- export declare enum LoginStatusSource {
14
- File = "file",
14
+ /**
15
+ * Where the CLI read the credential from — not who is acting and not how they
16
+ * authenticated. See {@link SessionIdentity} for those; the three are
17
+ * independent (a `Robot` credential normally carries a `User` identity).
18
+ */
19
+ export declare enum CredentialSource {
20
+ SavedLogin = "saved-login",
15
21
  Robot = "robot",
16
- Env = "env"
22
+ EnvironmentVariables = "env-vars"
17
23
  }
18
24
  export interface TokenRefreshTelemetry {
19
25
  attempted: boolean;
@@ -38,7 +44,14 @@ export interface LoginStatus {
38
44
  issuer?: string;
39
45
  expiration?: Date;
40
46
  hint?: string;
41
- source?: LoginStatusSource;
47
+ source?: CredentialSource;
48
+ /**
49
+ * Who the session acts as, read from the access token's claims. Present
50
+ * whenever a token is available to derive it from — including `"Expired"`,
51
+ * so the user can see whose session lapsed. Display only: the claims are
52
+ * not signature-verified.
53
+ */
54
+ identity?: SessionIdentity;
42
55
  /**
43
56
  * True when a refresh rotated successfully at the identity server but
44
57
  * persisting the new pair to disk failed. The returned `accessToken` is
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Minimal structural view of `@uipath/robot-client` — covers only the two
3
- * methods we consume. Defined locally so that this file compiles even when
4
- * the package is absent (it is loaded via dynamic `import()` at runtime).
3
+ * methods we consume. Defined locally so this file compiles without the
4
+ * package present: auth never imports robot-client, it only shapes the value
5
+ * returned by the host-registered loader (see {@link registerRobotClientLoader}).
5
6
  */
6
7
  interface IInteractiveConnectFlow {
7
8
  IsEnabled(): Promise<boolean>;
@@ -42,6 +43,19 @@ export interface RobotClientFallbackOptions {
42
43
  */
43
44
  force?: boolean;
44
45
  }
46
+ /** Host-provided loader for `@uipath/robot-client`. See {@link registerRobotClientLoader}. */
47
+ export type RobotClientModuleLoader = () => Promise<unknown>;
48
+ /**
49
+ * Register the host's loader for `@uipath/robot-client` (a private GitHub
50
+ * Package Registry package). The CLI host bundles robot-client once and calls
51
+ * this at startup with `() => import("@uipath/robot-client")`; auth's Robot
52
+ * credential fallback then loads the module through the host instead of every
53
+ * tool bundle inlining its own ~720KB copy. When no loader is registered (or it
54
+ * fails), the fallback resolves to `undefined` and callers degrade to the
55
+ * standard "Not logged in" path — the same behaviour as when the Robot service
56
+ * is absent.
57
+ */
58
+ export declare const registerRobotClientLoader: (loader: RobotClientModuleLoader) => void;
45
59
  /**
46
60
  * Read credentials from the running UiPath Robot/Assistant via its local IPC.
47
61
  *
@@ -52,7 +66,8 @@ export interface RobotClientFallbackOptions {
52
66
  * `options.force === true`
53
67
  * - the process looks like a CI runner (`CI`/`GITHUB_ACTIONS` set) — unless
54
68
  * `options.force === true`
55
- * - `@uipath/robot-client` is not installed or fails to load
69
+ * - no robot-client loader is registered (see `registerRobotClientLoader`),
70
+ * or the registered loader fails
56
71
  * - Robot is not running, or sign-in is disabled
57
72
  * - an IPC call exceeds the timeout
58
73
  * - the returned resource URL or access token is malformed/empty
package/dist/server.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export declare const AUTH_TIMEOUT_ERROR_CODE = "EAUTHTIMEOUT";
1
+ import { AUTH_TIMEOUT_ERROR_CODE } from "./constants";
2
+ export { AUTH_TIMEOUT_ERROR_CODE };
2
3
  interface StartCallbackServerProps {
3
4
  redirectUri: URL;
4
5
  timeoutMs?: number;
@@ -12,4 +13,3 @@ interface StartCallbackServerProps {
12
13
  signal?: AbortSignal;
13
14
  }
14
15
  export declare const startServer: ({ redirectUri, timeoutMs, onListening, signal, }: StartCallbackServerProps) => Promise<URL>;
15
- export {};
@@ -0,0 +1,35 @@
1
+ import type { AuthFlow } from "./types";
2
+ /**
3
+ * Whether the session acts as a person or as an external application.
4
+ * Deliberately coarse — `authFlow` carries the precision.
5
+ */
6
+ export type IdentityType = "User" | "Application";
7
+ /**
8
+ * Who the current session acts as, as reported by the access token.
9
+ *
10
+ * Every field here is read from *unverified* token claims (base64 decode, no
11
+ * signature check) and exists to be shown to a human. Never branch on it for
12
+ * an authorization or trust decision.
13
+ */
14
+ export interface SessionIdentity {
15
+ type: IdentityType;
16
+ /** Absent when the CLI did not run the flow itself (e.g. Robot-borrowed). */
17
+ authFlow?: AuthFlow;
18
+ /** User identities only — the token's `sub`. */
19
+ userId?: string;
20
+ userEmail?: string;
21
+ userName?: string;
22
+ /**
23
+ * Application identities only. User tokens also carry a `client_id` — the
24
+ * CLI's own — and surfacing that would read as if an app were acting.
25
+ */
26
+ clientId?: string;
27
+ }
28
+ /** Narrow an on-disk `UIPATH_AUTH_FLOW` value to a known flow. */
29
+ export declare const parseAuthFlow: (value: string | undefined) => AuthFlow | undefined;
30
+ /**
31
+ * Derive the acting identity from an access token and, when known, the flow
32
+ * that produced it. Returns undefined when neither says anything — better to
33
+ * omit the fields than to guess at who is acting.
34
+ */
35
+ export declare const resolveSessionIdentity: (accessToken: string | undefined, authFlow?: AuthFlow) => SessionIdentity | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/auth",
3
3
  "license": "MIT",
4
- "version": "1.199.0",
4
+ "version": "1.201.0-preview.115",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/UiPath/cli.git",
@@ -37,5 +37,5 @@
37
37
  "mihaigirleanu",
38
38
  "vlad-uipath"
39
39
  ],
40
- "gitHead": "723e6801b77b5926ba75e75b6a756cc38b1b7adc"
40
+ "gitHead": "f1086b73654d7728cb71f280588b3e0c77d535fc"
41
41
  }