@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.
- package/dist/constants.d.ts +1 -0
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +100 -16
- package/dist/index.d.ts +3 -2
- package/dist/index.js +274 -18392
- package/dist/loginStatus.d.ts +17 -4
- package/dist/robotClientFallback.d.ts +18 -3
- package/dist/server.d.ts +2 -2
- package/dist/sessionIdentity.d.ts +35 -0
- package/package.json +2 -2
package/dist/constants.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const AUTH_FILENAME = ".auth";
|
|
|
6
6
|
export declare const DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
7
7
|
/** Auth callback server timeout (5 minutes). */
|
|
8
8
|
export declare const DEFAULT_AUTH_TIMEOUT_MS: number;
|
|
9
|
+
export declare const AUTH_TIMEOUT_ERROR_CODE = "EAUTHTIMEOUT";
|
|
9
10
|
export declare const AUTH_CANCELLED_ERROR_CODE = "EAUTHCANCELLED";
|
|
10
11
|
/** Localhost OIDC redirect URI. */
|
|
11
12
|
export declare const DEFAULT_REDIRECT_URI = "http://localhost:8104/oidc/login";
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./clientCredentials";
|
|
|
4
4
|
export { type AuthFileConfig, InvalidBaseUrlError, setAuthFileConfig, } from "./config";
|
|
5
5
|
export * from "./loginStatus";
|
|
6
6
|
export * from "./logout";
|
|
7
|
+
export { type IdentityType, parseAuthFlow, resolveSessionIdentity, type SessionIdentity, } from "./sessionIdentity";
|
|
7
8
|
export { fetchTenantsAndOrganizations, type Tenant, type TenantsAndOrganizations, } from "./tenantSelection";
|
|
8
9
|
export * from "./tokenRefresh";
|
|
9
10
|
export { AUTH_FLOW_ENV_VAR, type AuthFlow, type BaseCredentials, } from "./types";
|
package/dist/index.browser.js
CHANGED
|
@@ -18452,6 +18452,67 @@ var getTokenExpiration = (accessToken) => {
|
|
|
18452
18452
|
}
|
|
18453
18453
|
};
|
|
18454
18454
|
|
|
18455
|
+
// src/sessionIdentity.ts
|
|
18456
|
+
var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
|
|
18457
|
+
var decodeClaims = (accessToken) => {
|
|
18458
|
+
const [error, claims] = catchError(() => parseJWT(accessToken));
|
|
18459
|
+
return error ? undefined : claims;
|
|
18460
|
+
};
|
|
18461
|
+
var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
18462
|
+
var resolveIdentityType = (claims, authFlow, email) => {
|
|
18463
|
+
const subType = asString(claims?.sub_type);
|
|
18464
|
+
if (subType) {
|
|
18465
|
+
return subType.startsWith("service") ? "Application" : "User";
|
|
18466
|
+
}
|
|
18467
|
+
if (authFlow) {
|
|
18468
|
+
return authFlow === "authorization_code" ? "User" : "Application";
|
|
18469
|
+
}
|
|
18470
|
+
if (email)
|
|
18471
|
+
return "User";
|
|
18472
|
+
if (asString(claims?.client_id) && !asString(claims?.sub)) {
|
|
18473
|
+
return "Application";
|
|
18474
|
+
}
|
|
18475
|
+
return;
|
|
18476
|
+
};
|
|
18477
|
+
var looksLikeEmail = (value) => value?.includes("@") ?? false;
|
|
18478
|
+
var pickEmail = (claims) => {
|
|
18479
|
+
for (const candidate of [claims?.email, claims?.preferred_username]) {
|
|
18480
|
+
const value = asString(candidate);
|
|
18481
|
+
if (looksLikeEmail(value))
|
|
18482
|
+
return value;
|
|
18483
|
+
}
|
|
18484
|
+
return;
|
|
18485
|
+
};
|
|
18486
|
+
var pickName = (claims) => {
|
|
18487
|
+
const username = asString(claims?.preferred_username);
|
|
18488
|
+
return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
|
|
18489
|
+
};
|
|
18490
|
+
var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
18491
|
+
const claims = accessToken ? decodeClaims(accessToken) : undefined;
|
|
18492
|
+
const email = pickEmail(claims);
|
|
18493
|
+
const type = resolveIdentityType(claims, authFlow, email);
|
|
18494
|
+
if (!type)
|
|
18495
|
+
return;
|
|
18496
|
+
const identity = { type };
|
|
18497
|
+
if (authFlow)
|
|
18498
|
+
identity.authFlow = authFlow;
|
|
18499
|
+
if (type === "User") {
|
|
18500
|
+
const userId = asString(claims?.sub);
|
|
18501
|
+
if (userId)
|
|
18502
|
+
identity.userId = userId;
|
|
18503
|
+
if (email)
|
|
18504
|
+
identity.userEmail = email;
|
|
18505
|
+
const name = pickName(claims);
|
|
18506
|
+
if (name)
|
|
18507
|
+
identity.userName = name;
|
|
18508
|
+
return identity;
|
|
18509
|
+
}
|
|
18510
|
+
const clientId = asString(claims?.client_id);
|
|
18511
|
+
if (clientId)
|
|
18512
|
+
identity.clientId = clientId;
|
|
18513
|
+
return identity;
|
|
18514
|
+
};
|
|
18515
|
+
|
|
18455
18516
|
// src/envAuth.ts
|
|
18456
18517
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
18457
18518
|
var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
|
|
@@ -18501,6 +18562,7 @@ var readAuthFromEnv = () => {
|
|
|
18501
18562
|
}
|
|
18502
18563
|
const expiration = getTokenExpiration(accessToken);
|
|
18503
18564
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
18565
|
+
const identity = resolveSessionIdentity(accessToken);
|
|
18504
18566
|
return {
|
|
18505
18567
|
loginStatus,
|
|
18506
18568
|
accessToken,
|
|
@@ -18510,7 +18572,8 @@ var readAuthFromEnv = () => {
|
|
|
18510
18572
|
tenantName,
|
|
18511
18573
|
tenantId,
|
|
18512
18574
|
expiration,
|
|
18513
|
-
source: "env" /*
|
|
18575
|
+
source: "env-vars" /* EnvironmentVariables */,
|
|
18576
|
+
...identity ? { identity } : {}
|
|
18514
18577
|
};
|
|
18515
18578
|
};
|
|
18516
18579
|
|
|
@@ -18627,8 +18690,17 @@ var parseResourceUrl = (url) => {
|
|
|
18627
18690
|
tenantName: segments[1]
|
|
18628
18691
|
};
|
|
18629
18692
|
};
|
|
18693
|
+
var ROBOT_CLIENT_LOADER_KEY = Symbol.for("@uipath/auth/RobotClientLoader");
|
|
18694
|
+
var getRegisteredRobotClientLoader = () => {
|
|
18695
|
+
const loader = globalThis[ROBOT_CLIENT_LOADER_KEY];
|
|
18696
|
+
return typeof loader === "function" ? loader : undefined;
|
|
18697
|
+
};
|
|
18630
18698
|
var defaultLoadModule = async () => {
|
|
18631
|
-
const
|
|
18699
|
+
const hostLoader = getRegisteredRobotClientLoader();
|
|
18700
|
+
if (!hostLoader) {
|
|
18701
|
+
return;
|
|
18702
|
+
}
|
|
18703
|
+
const [error, mod] = await catchError(() => hostLoader());
|
|
18632
18704
|
if (error || !mod) {
|
|
18633
18705
|
return;
|
|
18634
18706
|
}
|
|
@@ -18754,6 +18826,9 @@ var refreshAccessToken = async ({
|
|
|
18754
18826
|
return { accessToken: newAccessToken, refreshToken: newRefreshToken };
|
|
18755
18827
|
};
|
|
18756
18828
|
|
|
18829
|
+
// src/types.ts
|
|
18830
|
+
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
18831
|
+
|
|
18757
18832
|
// src/utils/envFile.ts
|
|
18758
18833
|
import { getFileSystem as getFileSystem4 } from "@uipath/filesystem";
|
|
18759
18834
|
var DEFAULT_AUTH_FILENAME = AUTH_FILENAME;
|
|
@@ -18916,12 +18991,12 @@ var saveEnvFileAsync = async ({
|
|
|
18916
18991
|
};
|
|
18917
18992
|
|
|
18918
18993
|
// src/loginStatus.ts
|
|
18919
|
-
var
|
|
18920
|
-
((
|
|
18921
|
-
|
|
18922
|
-
|
|
18923
|
-
|
|
18924
|
-
})(
|
|
18994
|
+
var CredentialSource;
|
|
18995
|
+
((CredentialSource2) => {
|
|
18996
|
+
CredentialSource2["SavedLogin"] = "saved-login";
|
|
18997
|
+
CredentialSource2["Robot"] = "robot";
|
|
18998
|
+
CredentialSource2["EnvironmentVariables"] = "env-vars";
|
|
18999
|
+
})(CredentialSource ||= {});
|
|
18925
19000
|
var getLoginStatusAsync = async (options = {}) => {
|
|
18926
19001
|
return getLoginStatusWithDeps(options);
|
|
18927
19002
|
};
|
|
@@ -19127,7 +19202,8 @@ async function buildFileStatus(tokens, credentials, globalHint) {
|
|
|
19127
19202
|
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
19128
19203
|
tenantId: credentials.UIPATH_TENANT_ID,
|
|
19129
19204
|
expiration: tokens.expiration,
|
|
19130
|
-
source: "
|
|
19205
|
+
source: "saved-login" /* SavedLogin */,
|
|
19206
|
+
...identityFields(tokens.accessToken, credentials),
|
|
19131
19207
|
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
19132
19208
|
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
19133
19209
|
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
@@ -19140,7 +19216,12 @@ async function buildFileStatus(tokens, credentials, globalHint) {
|
|
|
19140
19216
|
}
|
|
19141
19217
|
return result;
|
|
19142
19218
|
}
|
|
19219
|
+
function identityFields(accessToken, credentials) {
|
|
19220
|
+
const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
|
|
19221
|
+
return identity ? { identity } : {};
|
|
19222
|
+
}
|
|
19143
19223
|
function buildRobotStatus(robotCreds) {
|
|
19224
|
+
const identity = resolveSessionIdentity(robotCreds.accessToken);
|
|
19144
19225
|
return {
|
|
19145
19226
|
loginStatus: "Logged in",
|
|
19146
19227
|
accessToken: robotCreds.accessToken,
|
|
@@ -19151,7 +19232,8 @@ function buildRobotStatus(robotCreds) {
|
|
|
19151
19232
|
tenantId: robotCreds.tenantId,
|
|
19152
19233
|
issuer: robotCreds.issuer,
|
|
19153
19234
|
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
19154
|
-
source: "robot" /* Robot
|
|
19235
|
+
source: "robot" /* Robot */,
|
|
19236
|
+
...identity ? { identity } : {}
|
|
19155
19237
|
};
|
|
19156
19238
|
}
|
|
19157
19239
|
var isFileNotFoundError = (error) => {
|
|
@@ -19202,7 +19284,8 @@ async function circuitBreakerShortCircuit(ctx) {
|
|
|
19202
19284
|
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
19203
19285
|
tenantId: credentials.UIPATH_TENANT_ID,
|
|
19204
19286
|
expiration,
|
|
19205
|
-
source: "
|
|
19287
|
+
source: "saved-login" /* SavedLogin */,
|
|
19288
|
+
...identityFields(accessToken, credentials)
|
|
19206
19289
|
} : {},
|
|
19207
19290
|
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
19208
19291
|
refreshCircuitOpen: true,
|
|
@@ -19224,7 +19307,8 @@ async function lockAcquireFailureStatus(ctx, error) {
|
|
|
19224
19307
|
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
19225
19308
|
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
19226
19309
|
expiration: ctx.expiration,
|
|
19227
|
-
source: "
|
|
19310
|
+
source: "saved-login" /* SavedLogin */,
|
|
19311
|
+
...identityFields(ctx.accessToken, ctx.credentials),
|
|
19228
19312
|
hint: globalHint,
|
|
19229
19313
|
tokenRefresh: {
|
|
19230
19314
|
attempted: false,
|
|
@@ -19612,18 +19696,18 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
19612
19696
|
const data = await response.json();
|
|
19613
19697
|
return data;
|
|
19614
19698
|
};
|
|
19615
|
-
// src/types.ts
|
|
19616
|
-
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
19617
19699
|
export {
|
|
19618
19700
|
setAuthFileConfig,
|
|
19619
19701
|
setActiveAuthProfile,
|
|
19620
19702
|
saveEnvFileAsync,
|
|
19621
19703
|
runWithAuthProfile,
|
|
19704
|
+
resolveSessionIdentity,
|
|
19622
19705
|
resolveEnvFilePathAsync,
|
|
19623
19706
|
resolveEnvFileLocationAsync,
|
|
19624
19707
|
resolveAuthProfileFilePath,
|
|
19625
19708
|
refreshAccessToken,
|
|
19626
19709
|
parseJWT,
|
|
19710
|
+
parseAuthFlow,
|
|
19627
19711
|
normalizeAuthProfileName,
|
|
19628
19712
|
logoutWithDeps,
|
|
19629
19713
|
logout,
|
|
@@ -19641,14 +19725,14 @@ export {
|
|
|
19641
19725
|
clientCredentialsLogin,
|
|
19642
19726
|
clearActiveAuthProfile,
|
|
19643
19727
|
TokenRefreshOAuthError,
|
|
19644
|
-
LoginStatusSource,
|
|
19645
19728
|
InvalidBaseUrlError,
|
|
19646
19729
|
DEFAULT_ENV_FILENAME,
|
|
19647
19730
|
DEFAULT_AUTH_PROFILE,
|
|
19648
19731
|
DEFAULT_AUTH_FILENAME,
|
|
19732
|
+
CredentialSource,
|
|
19649
19733
|
ClientCredentialsAuthenticationError,
|
|
19650
19734
|
AuthProfileValidationError,
|
|
19651
19735
|
AUTH_FLOW_ENV_VAR
|
|
19652
19736
|
};
|
|
19653
19737
|
|
|
19654
|
-
//# debugId=
|
|
19738
|
+
//# debugId=A433BD3381C7E18264756E2164756E21
|
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,16 @@ export * from "./authContext";
|
|
|
2
2
|
export * from "./authProfile";
|
|
3
3
|
export * from "./clientCredentials";
|
|
4
4
|
export { type AuthFileConfig, InvalidBaseUrlError, setAuthFileConfig, } from "./config";
|
|
5
|
-
export { AUTH_CANCELLED_ERROR_CODE } from "./constants";
|
|
5
|
+
export { AUTH_CANCELLED_ERROR_CODE, AUTH_TIMEOUT_ERROR_CODE, DEFAULT_AUTH_TIMEOUT_MS, } from "./constants";
|
|
6
6
|
export { ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_ENABLE_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, } from "./envAuth";
|
|
7
7
|
export { FederatedCredentialsAuthenticationError, federatedCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, } from "./federatedCredentials";
|
|
8
8
|
export * from "./interactive";
|
|
9
9
|
export * from "./loginStatus";
|
|
10
10
|
export * from "./logout";
|
|
11
11
|
export { clearRefreshBreaker, loadRefreshBreaker, type RefreshBreakerState, refreshTokenFingerprint, saveRefreshBreaker, } from "./refreshCircuitBreaker";
|
|
12
|
+
export { type RobotClientModuleLoader, registerRobotClientLoader, } from "./robotClientFallback";
|
|
12
13
|
export { INVALID_TENANT_CODE, InvalidTenantError, isTenantSelectionError, type SelectFromList, selectTenantWithDeps, TENANT_SELECTION_REQUIRED_CODE, TenantSelectionError, TenantSelectionRequiredError, } from "./selectTenant";
|
|
13
|
-
export {
|
|
14
|
+
export { type IdentityType, parseAuthFlow, resolveSessionIdentity, type SessionIdentity, } from "./sessionIdentity";
|
|
14
15
|
export { fetchTenantsAndOrganizations, type Tenant, type TenantsAndOrganizations, } from "./tenantSelection";
|
|
15
16
|
export * from "./tokenRefresh";
|
|
16
17
|
export { AUTH_FLOW_ENV_VAR, type AuthFlow, type BaseCredentials, } from "./types";
|