@uipath/codedapp-tool 1.200.0-preview.120 → 1.201.0-preview.121
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/{browser-strategy-v4n9zxyf.js → browser-strategy-16yagjhr.js} +1 -1
- package/dist/index-4tmzxx6y.js +18292 -0
- package/dist/index-9f8q2ege.js +2058 -0
- package/dist/index-hsadteg4.js +634 -0
- package/dist/{index-z6sptz1r.js → index-y19pndcy.js} +11 -8
- package/dist/index.js +8 -6
- package/dist/js-yaml-cggj6w7q.js +3145 -0
- package/dist/node-strategy-gfq7k0sx.js +348 -0
- package/dist/tool-25qmnad0.js +6690 -0
- package/dist/tool-4pvh3k50.js +265 -0
- package/dist/{tool-v6xshdxt.js → tool-hcf6wh0m.js} +54204 -65512
- package/dist/{tool-1snc64g4.js → tool-q42rrs00.js} +3 -2
- package/dist/{tool-k7c9wf29.js → tool-yadq0xpc.js} +109 -23
- package/dist/tool.js +6 -5
- package/package.json +2 -2
- package/dist/node-strategy-0s9nhcmn.js +0 -63
- package/dist/tool-7ktmqc73.js +0 -1161
|
@@ -3,9 +3,10 @@ var UIPATH_HOME_DIR = ".uipath";
|
|
|
3
3
|
var AUTH_FILENAME = ".auth";
|
|
4
4
|
var DEFAULT_BASE_URL = "https://cloud.uipath.com";
|
|
5
5
|
var DEFAULT_AUTH_TIMEOUT_MS = 5 * 60 * 1000;
|
|
6
|
+
var AUTH_TIMEOUT_ERROR_CODE = "EAUTHTIMEOUT";
|
|
6
7
|
var AUTH_CANCELLED_ERROR_CODE = "EAUTHCANCELLED";
|
|
7
8
|
var DEFAULT_REDIRECT_URI = "http://localhost:8104/oidc/login";
|
|
8
9
|
|
|
9
|
-
export { UIPATH_HOME_DIR, AUTH_FILENAME, DEFAULT_BASE_URL, DEFAULT_AUTH_TIMEOUT_MS, AUTH_CANCELLED_ERROR_CODE, DEFAULT_REDIRECT_URI };
|
|
10
|
+
export { UIPATH_HOME_DIR, AUTH_FILENAME, DEFAULT_BASE_URL, DEFAULT_AUTH_TIMEOUT_MS, AUTH_TIMEOUT_ERROR_CODE, AUTH_CANCELLED_ERROR_CODE, DEFAULT_REDIRECT_URI };
|
|
10
11
|
|
|
11
|
-
//# debugId=
|
|
12
|
+
//# debugId=0F56C5D203AAAAAA64756E2164756E21
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
catchError,
|
|
7
7
|
getFileSystem
|
|
8
|
-
} from "./tool-
|
|
8
|
+
} from "./tool-4pvh3k50.js";
|
|
9
9
|
import {
|
|
10
10
|
AUTH_FILENAME,
|
|
11
11
|
DEFAULT_BASE_URL,
|
|
12
12
|
DEFAULT_REDIRECT_URI,
|
|
13
13
|
UIPATH_HOME_DIR
|
|
14
|
-
} from "./tool-
|
|
14
|
+
} from "./tool-q42rrs00.js";
|
|
15
15
|
import {
|
|
16
16
|
__require
|
|
17
17
|
} from "./tool-wckvcay0.js";
|
|
@@ -911,6 +911,67 @@ var getTokenExpiration = (accessToken) => {
|
|
|
911
911
|
}
|
|
912
912
|
};
|
|
913
913
|
|
|
914
|
+
// ../auth/src/sessionIdentity.ts
|
|
915
|
+
var parseAuthFlow = (value) => value === "authorization_code" || value === "client_credentials" || value === "federated_credentials" ? value : undefined;
|
|
916
|
+
var decodeClaims = (accessToken) => {
|
|
917
|
+
const [error, claims] = catchError(() => parseJWT(accessToken));
|
|
918
|
+
return error ? undefined : claims;
|
|
919
|
+
};
|
|
920
|
+
var asString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
921
|
+
var resolveIdentityType = (claims, authFlow, email) => {
|
|
922
|
+
const subType = asString(claims?.sub_type);
|
|
923
|
+
if (subType) {
|
|
924
|
+
return subType.startsWith("service") ? "Application" : "User";
|
|
925
|
+
}
|
|
926
|
+
if (authFlow) {
|
|
927
|
+
return authFlow === "authorization_code" ? "User" : "Application";
|
|
928
|
+
}
|
|
929
|
+
if (email)
|
|
930
|
+
return "User";
|
|
931
|
+
if (asString(claims?.client_id) && !asString(claims?.sub)) {
|
|
932
|
+
return "Application";
|
|
933
|
+
}
|
|
934
|
+
return;
|
|
935
|
+
};
|
|
936
|
+
var looksLikeEmail = (value) => value?.includes("@") ?? false;
|
|
937
|
+
var pickEmail = (claims) => {
|
|
938
|
+
for (const candidate of [claims?.email, claims?.preferred_username]) {
|
|
939
|
+
const value = asString(candidate);
|
|
940
|
+
if (looksLikeEmail(value))
|
|
941
|
+
return value;
|
|
942
|
+
}
|
|
943
|
+
return;
|
|
944
|
+
};
|
|
945
|
+
var pickName = (claims) => {
|
|
946
|
+
const username = asString(claims?.preferred_username);
|
|
947
|
+
return asString(claims?.name) ?? (looksLikeEmail(username) ? undefined : username);
|
|
948
|
+
};
|
|
949
|
+
var resolveSessionIdentity = (accessToken, authFlow) => {
|
|
950
|
+
const claims = accessToken ? decodeClaims(accessToken) : undefined;
|
|
951
|
+
const email = pickEmail(claims);
|
|
952
|
+
const type = resolveIdentityType(claims, authFlow, email);
|
|
953
|
+
if (!type)
|
|
954
|
+
return;
|
|
955
|
+
const identity = { type };
|
|
956
|
+
if (authFlow)
|
|
957
|
+
identity.authFlow = authFlow;
|
|
958
|
+
if (type === "User") {
|
|
959
|
+
const userId = asString(claims?.sub);
|
|
960
|
+
if (userId)
|
|
961
|
+
identity.userId = userId;
|
|
962
|
+
if (email)
|
|
963
|
+
identity.userEmail = email;
|
|
964
|
+
const name = pickName(claims);
|
|
965
|
+
if (name)
|
|
966
|
+
identity.userName = name;
|
|
967
|
+
return identity;
|
|
968
|
+
}
|
|
969
|
+
const clientId = asString(claims?.client_id);
|
|
970
|
+
if (clientId)
|
|
971
|
+
identity.clientId = clientId;
|
|
972
|
+
return identity;
|
|
973
|
+
};
|
|
974
|
+
|
|
914
975
|
// ../auth/src/envAuth.ts
|
|
915
976
|
var ENV_AUTH_ENABLE_VAR = "UIPATH_CLI_ENABLE_ENV_AUTH";
|
|
916
977
|
var ENFORCE_ROBOT_AUTH_VAR = "UIPATH_CLI_ENFORCE_ROBOT_AUTH";
|
|
@@ -960,6 +1021,7 @@ var readAuthFromEnv = () => {
|
|
|
960
1021
|
}
|
|
961
1022
|
const expiration = getTokenExpiration(accessToken);
|
|
962
1023
|
const loginStatus = expiration && expiration <= new Date ? "Expired" : "Logged in";
|
|
1024
|
+
const identity = resolveSessionIdentity(accessToken);
|
|
963
1025
|
return {
|
|
964
1026
|
loginStatus,
|
|
965
1027
|
accessToken,
|
|
@@ -969,7 +1031,8 @@ var readAuthFromEnv = () => {
|
|
|
969
1031
|
tenantName,
|
|
970
1032
|
tenantId,
|
|
971
1033
|
expiration,
|
|
972
|
-
source: "env" /*
|
|
1034
|
+
source: "env-vars" /* EnvironmentVariables */,
|
|
1035
|
+
...identity ? { identity } : {}
|
|
973
1036
|
};
|
|
974
1037
|
};
|
|
975
1038
|
|
|
@@ -1223,6 +1286,9 @@ var refreshAccessToken = async ({
|
|
|
1223
1286
|
return { accessToken: newAccessToken, refreshToken: newRefreshToken };
|
|
1224
1287
|
};
|
|
1225
1288
|
|
|
1289
|
+
// ../auth/src/types.ts
|
|
1290
|
+
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
1291
|
+
|
|
1226
1292
|
// ../auth/src/utils/envFile.ts
|
|
1227
1293
|
var DEFAULT_AUTH_FILENAME = AUTH_FILENAME;
|
|
1228
1294
|
var DEFAULT_ENV_FILENAME = `${UIPATH_HOME_DIR}/${AUTH_FILENAME}`;
|
|
@@ -1384,12 +1450,12 @@ var saveEnvFileAsync = async ({
|
|
|
1384
1450
|
};
|
|
1385
1451
|
|
|
1386
1452
|
// ../auth/src/loginStatus.ts
|
|
1387
|
-
var
|
|
1388
|
-
((
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
})(
|
|
1453
|
+
var CredentialSource;
|
|
1454
|
+
((CredentialSource2) => {
|
|
1455
|
+
CredentialSource2["SavedLogin"] = "saved-login";
|
|
1456
|
+
CredentialSource2["Robot"] = "robot";
|
|
1457
|
+
CredentialSource2["EnvironmentVariables"] = "env-vars";
|
|
1458
|
+
})(CredentialSource ||= {});
|
|
1393
1459
|
var getLoginStatusAsync = async (options = {}) => {
|
|
1394
1460
|
return getLoginStatusWithDeps(options);
|
|
1395
1461
|
};
|
|
@@ -1595,7 +1661,8 @@ async function buildFileStatus(tokens, credentials, globalHint) {
|
|
|
1595
1661
|
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
1596
1662
|
tenantId: credentials.UIPATH_TENANT_ID,
|
|
1597
1663
|
expiration: tokens.expiration,
|
|
1598
|
-
source: "
|
|
1664
|
+
source: "saved-login" /* SavedLogin */,
|
|
1665
|
+
...identityFields(tokens.accessToken, credentials),
|
|
1599
1666
|
...tokens.persistenceWarning ? { hint: tokens.persistenceWarning, persistenceFailed: true } : {},
|
|
1600
1667
|
...tokens.lockReleaseFailed ? { lockReleaseFailed: true } : {},
|
|
1601
1668
|
...tokens.tokenRefresh ? { tokenRefresh: tokens.tokenRefresh } : {}
|
|
@@ -1608,7 +1675,12 @@ async function buildFileStatus(tokens, credentials, globalHint) {
|
|
|
1608
1675
|
}
|
|
1609
1676
|
return result;
|
|
1610
1677
|
}
|
|
1678
|
+
function identityFields(accessToken, credentials) {
|
|
1679
|
+
const identity = resolveSessionIdentity(accessToken, parseAuthFlow(credentials[AUTH_FLOW_ENV_VAR]));
|
|
1680
|
+
return identity ? { identity } : {};
|
|
1681
|
+
}
|
|
1611
1682
|
function buildRobotStatus(robotCreds) {
|
|
1683
|
+
const identity = resolveSessionIdentity(robotCreds.accessToken);
|
|
1612
1684
|
return {
|
|
1613
1685
|
loginStatus: "Logged in",
|
|
1614
1686
|
accessToken: robotCreds.accessToken,
|
|
@@ -1619,7 +1691,8 @@ function buildRobotStatus(robotCreds) {
|
|
|
1619
1691
|
tenantId: robotCreds.tenantId,
|
|
1620
1692
|
issuer: robotCreds.issuer,
|
|
1621
1693
|
expiration: getTokenExpiration(robotCreds.accessToken),
|
|
1622
|
-
source: "robot" /* Robot
|
|
1694
|
+
source: "robot" /* Robot */,
|
|
1695
|
+
...identity ? { identity } : {}
|
|
1623
1696
|
};
|
|
1624
1697
|
}
|
|
1625
1698
|
var isFileNotFoundError = (error) => {
|
|
@@ -1670,7 +1743,8 @@ async function circuitBreakerShortCircuit(ctx) {
|
|
|
1670
1743
|
tenantName: credentials.UIPATH_TENANT_NAME,
|
|
1671
1744
|
tenantId: credentials.UIPATH_TENANT_ID,
|
|
1672
1745
|
expiration,
|
|
1673
|
-
source: "
|
|
1746
|
+
source: "saved-login" /* SavedLogin */,
|
|
1747
|
+
...identityFields(accessToken, credentials)
|
|
1674
1748
|
} : {},
|
|
1675
1749
|
hint: globalHint ?? (tokenIsDead ? deadHint : backoffHint),
|
|
1676
1750
|
refreshCircuitOpen: true,
|
|
@@ -1692,7 +1766,8 @@ async function lockAcquireFailureStatus(ctx, error) {
|
|
|
1692
1766
|
tenantName: ctx.credentials.UIPATH_TENANT_NAME,
|
|
1693
1767
|
tenantId: ctx.credentials.UIPATH_TENANT_ID,
|
|
1694
1768
|
expiration: ctx.expiration,
|
|
1695
|
-
source: "
|
|
1769
|
+
source: "saved-login" /* SavedLogin */,
|
|
1770
|
+
...identityFields(ctx.accessToken, ctx.credentials),
|
|
1696
1771
|
hint: globalHint,
|
|
1697
1772
|
tokenRefresh: {
|
|
1698
1773
|
attempted: false,
|
|
@@ -2086,6 +2161,16 @@ var federatedCredentialsLogin = async ({
|
|
|
2086
2161
|
});
|
|
2087
2162
|
};
|
|
2088
2163
|
// ../auth/src/tenantSelection.ts
|
|
2164
|
+
var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
|
|
2165
|
+
var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
|
|
2166
|
+
var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
|
|
2167
|
+
var describeNonJsonResponse = (organizationId, response, parseError) => {
|
|
2168
|
+
if (response.redirected) {
|
|
2169
|
+
return `Could not find organization '${organizationId}': the request was ` + `redirected to a sign-in page instead of the organization's tenant ` + `list. ${LOGIN_STATUS_HINT}`;
|
|
2170
|
+
}
|
|
2171
|
+
const contentType = response.headers.get("content-type") ?? "unknown";
|
|
2172
|
+
return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
|
|
2173
|
+
};
|
|
2089
2174
|
var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId) => {
|
|
2090
2175
|
const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
|
|
2091
2176
|
const response = await fetch(url, {
|
|
@@ -2095,12 +2180,16 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
2095
2180
|
});
|
|
2096
2181
|
if (!response.ok) {
|
|
2097
2182
|
if (response.status === 401) {
|
|
2098
|
-
throw new Error(
|
|
2183
|
+
throw new Error(`Unauthorized: the access token was rejected, it was not ` + `issued for organization '${organizationId}', or ` + `'${organizationId}' was not accepted as an organization ` + `URL segment in this environment. ` + LOGIN_STATUS_HINT);
|
|
2099
2184
|
}
|
|
2100
2185
|
const errorText = await response.text();
|
|
2101
|
-
|
|
2186
|
+
const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
|
|
2187
|
+
throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
|
|
2188
|
+
}
|
|
2189
|
+
const [parseError, data] = await catchError(response.json());
|
|
2190
|
+
if (parseError) {
|
|
2191
|
+
throw new Error(describeNonJsonResponse(organizationId, response, parseError));
|
|
2102
2192
|
}
|
|
2103
|
-
const data = await response.json();
|
|
2104
2193
|
return data;
|
|
2105
2194
|
};
|
|
2106
2195
|
|
|
@@ -2179,9 +2268,6 @@ var selectTenantWithDeps = async (baseUrl, accessToken, organizationId, targetTe
|
|
|
2179
2268
|
return [selectedTenant.name, selectedTenant.id, organization.name];
|
|
2180
2269
|
};
|
|
2181
2270
|
|
|
2182
|
-
// ../auth/src/types.ts
|
|
2183
|
-
var AUTH_FLOW_ENV_VAR = "UIPATH_AUTH_FLOW";
|
|
2184
|
-
|
|
2185
2271
|
// ../auth/src/interactive.ts
|
|
2186
2272
|
var interactiveLoginWithDeps = async (options, deps) => {
|
|
2187
2273
|
const {
|
|
@@ -2458,10 +2544,10 @@ var authenticate = async ({
|
|
|
2458
2544
|
const authUrl = `${authorizationEndpoint}?${authParams.toString()}`;
|
|
2459
2545
|
let strategy;
|
|
2460
2546
|
if (isBrowser()) {
|
|
2461
|
-
const { BrowserAuthStrategy } = await import("./browser-strategy-
|
|
2547
|
+
const { BrowserAuthStrategy } = await import("./browser-strategy-16yagjhr.js");
|
|
2462
2548
|
strategy = new BrowserAuthStrategy;
|
|
2463
2549
|
} else {
|
|
2464
|
-
const { NodeAuthStrategy } = await import("./node-strategy-
|
|
2550
|
+
const { NodeAuthStrategy } = await import("./node-strategy-gfq7k0sx.js");
|
|
2465
2551
|
strategy = new NodeAuthStrategy;
|
|
2466
2552
|
}
|
|
2467
2553
|
const code = await strategy.execute(authUrl, effectiveRedirectUriUrl, state, {
|
|
@@ -2480,6 +2566,6 @@ var authenticate = async ({
|
|
|
2480
2566
|
});
|
|
2481
2567
|
};
|
|
2482
2568
|
|
|
2483
|
-
export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, parseJWT, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync,
|
|
2569
|
+
export { setAuthFileConfig, InvalidBaseUrlError, DEFAULT_AUTH_PROFILE, AuthProfileValidationError, normalizeAuthProfileName, setActiveAuthProfile, clearActiveAuthProfile, getActiveAuthProfile, runWithAuthProfile, resolveAuthProfileFilePath, getActiveAuthProfileFilePath, parseJWT, parseAuthFlow, resolveSessionIdentity, ENV_AUTH_ENABLE_VAR, ENFORCE_ROBOT_AUTH_VAR, ENV_AUTH_VARS, EnvAuthConfigError, isEnvAuthEnabled, isRobotAuthEnforced, readAuthFromEnv, refreshTokenFingerprint, loadRefreshBreaker, saveRefreshBreaker, clearRefreshBreaker, registerRobotClientLoader, TokenRefreshOAuthError, isTokenRefreshOAuthFailure, refreshAccessToken, AUTH_FLOW_ENV_VAR, DEFAULT_AUTH_FILENAME, DEFAULT_ENV_FILENAME, resolveEnvFileLocationAsync, resolveEnvFilePathAsync, loadEnvFileAsync, saveEnvFileAsync, CredentialSource, getLoginStatusAsync, getLoginStatusWithDeps, getAuthContext, getAuthEnv, ClientCredentialsAuthenticationError, clientCredentialsLogin, JWT_BEARER_ASSERTION_TYPE, FederatedCredentialsAuthenticationError, federatedCredentialsLogin, fetchTenantsAndOrganizations, TENANT_SELECTION_REQUIRED_CODE, INVALID_TENANT_CODE, TenantSelectionError, TenantSelectionRequiredError, InvalidTenantError, isTenantSelectionError, selectTenantWithDeps, interactiveLoginWithDeps, interactiveLogin, logoutWithDeps, logout, authenticate };
|
|
2484
2570
|
|
|
2485
|
-
//# debugId=
|
|
2571
|
+
//# debugId=AE89F90F78CF3CD464756E2164756E21
|
package/dist/tool.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
metadata,
|
|
3
3
|
registerCommands
|
|
4
|
-
} from "./tool-
|
|
4
|
+
} from "./tool-hcf6wh0m.js";
|
|
5
|
+
import"./tool-25qmnad0.js";
|
|
6
|
+
import"./tool-yadq0xpc.js";
|
|
5
7
|
import"./tool-y0g9grx6.js";
|
|
6
|
-
import"./tool-k7c9wf29.js";
|
|
7
8
|
import"./tool-0gctz400.js";
|
|
8
|
-
import"./tool-
|
|
9
|
-
import"./tool-
|
|
9
|
+
import"./tool-4pvh3k50.js";
|
|
10
|
+
import"./tool-q42rrs00.js";
|
|
10
11
|
import"./tool-wckvcay0.js";
|
|
11
12
|
export {
|
|
12
13
|
registerCommands,
|
|
13
14
|
metadata
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
//# debugId=
|
|
17
|
+
//# debugId=4B3BB7844263F9B364756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/codedapp-tool",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.201.0-preview.121",
|
|
5
5
|
"description": "Build, pack, publish, deploy, and manage UiPath Coded Web Applications.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"cli-tool",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"registry": "https://registry.npmjs.org/"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "c70ccfc0b12e637441d67df1d212b71d7784b5f8"
|
|
31
31
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
catchError,
|
|
3
|
-
getFileSystem,
|
|
4
|
-
startServer
|
|
5
|
-
} from "./tool-7ktmqc73.js";
|
|
6
|
-
import"./tool-1snc64g4.js";
|
|
7
|
-
import"./tool-wckvcay0.js";
|
|
8
|
-
|
|
9
|
-
// ../auth/src/strategies/node-strategy.ts
|
|
10
|
-
class NodeAuthStrategy {
|
|
11
|
-
async execute(url, redirectUri, expectedState, opts) {
|
|
12
|
-
const fs = getFileSystem();
|
|
13
|
-
const callbackUrl = await startServer({
|
|
14
|
-
redirectUri,
|
|
15
|
-
timeoutMs: opts?.timeoutMs,
|
|
16
|
-
signal: opts?.signal,
|
|
17
|
-
onListening: async () => {
|
|
18
|
-
let safeUrl = "";
|
|
19
|
-
for (const ch of url) {
|
|
20
|
-
const c = ch.charCodeAt(0);
|
|
21
|
-
if (c > 31 && (c < 128 || c > 159))
|
|
22
|
-
safeUrl += ch;
|
|
23
|
-
}
|
|
24
|
-
if (opts?.noBrowser) {
|
|
25
|
-
if (!opts.onAuthUrl) {
|
|
26
|
-
throw new Error("Headless login (noBrowser) requires an onAuthUrl handler " + "to surface the authorize URL, but none was provided.");
|
|
27
|
-
}
|
|
28
|
-
opts.onAuthUrl(safeUrl);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const [openError] = await catchError(fs.utils.open(url));
|
|
32
|
-
if (!openError)
|
|
33
|
-
return;
|
|
34
|
-
const isSpawnError = "code" in openError && openError.code === "ENOENT";
|
|
35
|
-
if (isSpawnError) {
|
|
36
|
-
throw new Error("Could not open a browser. No supported browser launcher was found. " + `On a headless or minimal system, use non-interactive login instead:
|
|
37
|
-
|
|
38
|
-
` + ` uip login --client-id <id> --client-secret <secret> -t <tenant>
|
|
39
|
-
|
|
40
|
-
` + "Or install a browser opener for your OS (e.g. xdg-utils on Linux).", { cause: openError });
|
|
41
|
-
}
|
|
42
|
-
throw new Error("Could not open the browser automatically. " + `Visit this URL to authenticate:
|
|
43
|
-
|
|
44
|
-
${safeUrl}
|
|
45
|
-
`, { cause: openError });
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const returnedState = callbackUrl.searchParams.get("state");
|
|
49
|
-
if (returnedState !== expectedState) {
|
|
50
|
-
throw new Error("OAuth state mismatch — the callback state does not match the expected value. " + "This may indicate a CSRF attack. Please try signing in again.");
|
|
51
|
-
}
|
|
52
|
-
const code = callbackUrl.searchParams.get("code");
|
|
53
|
-
if (!code) {
|
|
54
|
-
throw new Error("No authorization code received");
|
|
55
|
-
}
|
|
56
|
-
return code;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
NodeAuthStrategy
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
//# debugId=E5B2BD2B3B179D3D64756E2164756E21
|