@uipath/auth 1.201.0-preview.115 → 1.201.0-preview.122
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/index.browser.js +18 -4
- package/dist/index.js +18 -4
- package/dist/tenantSelection.d.ts +13 -1
- package/package.json +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -19679,6 +19679,16 @@ async function logout(options) {
|
|
|
19679
19679
|
return logoutWithDeps(options);
|
|
19680
19680
|
}
|
|
19681
19681
|
// src/tenantSelection.ts
|
|
19682
|
+
var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
|
|
19683
|
+
var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
|
|
19684
|
+
var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
|
|
19685
|
+
var describeNonJsonResponse = (organizationId, response, parseError) => {
|
|
19686
|
+
if (response.redirected) {
|
|
19687
|
+
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}`;
|
|
19688
|
+
}
|
|
19689
|
+
const contentType = response.headers.get("content-type") ?? "unknown";
|
|
19690
|
+
return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
|
|
19691
|
+
};
|
|
19682
19692
|
var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId) => {
|
|
19683
19693
|
const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
|
|
19684
19694
|
const response = await fetch(url, {
|
|
@@ -19688,12 +19698,16 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
19688
19698
|
});
|
|
19689
19699
|
if (!response.ok) {
|
|
19690
19700
|
if (response.status === 401) {
|
|
19691
|
-
throw new Error(
|
|
19701
|
+
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);
|
|
19692
19702
|
}
|
|
19693
19703
|
const errorText = await response.text();
|
|
19694
|
-
|
|
19704
|
+
const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
|
|
19705
|
+
throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
|
|
19706
|
+
}
|
|
19707
|
+
const [parseError, data] = await catchError(response.json());
|
|
19708
|
+
if (parseError) {
|
|
19709
|
+
throw new Error(describeNonJsonResponse(organizationId, response, parseError));
|
|
19695
19710
|
}
|
|
19696
|
-
const data = await response.json();
|
|
19697
19711
|
return data;
|
|
19698
19712
|
};
|
|
19699
19713
|
export {
|
|
@@ -19735,4 +19749,4 @@ export {
|
|
|
19735
19749
|
AUTH_FLOW_ENV_VAR
|
|
19736
19750
|
};
|
|
19737
19751
|
|
|
19738
|
-
//# debugId=
|
|
19752
|
+
//# debugId=7467DDE1FA7C205564756E2164756E21
|
package/dist/index.js
CHANGED
|
@@ -3547,6 +3547,16 @@ var federatedCredentialsLogin = async ({
|
|
|
3547
3547
|
init_src();
|
|
3548
3548
|
|
|
3549
3549
|
// src/tenantSelection.ts
|
|
3550
|
+
var LOGIN_STATUS_HINT = "Run 'uip login status' to see the organization the CLI is signed in to.";
|
|
3551
|
+
var organizationHint = (organizationId) => `The request used '${organizationId}' as the organization. ${LOGIN_STATUS_HINT}`;
|
|
3552
|
+
var IDENTIFIER_STATUSES = new Set([400, 403, 404]);
|
|
3553
|
+
var describeNonJsonResponse = (organizationId, response, parseError) => {
|
|
3554
|
+
if (response.redirected) {
|
|
3555
|
+
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}`;
|
|
3556
|
+
}
|
|
3557
|
+
const contentType = response.headers.get("content-type") ?? "unknown";
|
|
3558
|
+
return `The organization service returned a '${contentType}' response instead ` + `of JSON: ${parseError.message}. ${organizationHint(organizationId)}`;
|
|
3559
|
+
};
|
|
3550
3560
|
var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId) => {
|
|
3551
3561
|
const url = `${baseUrl}/${organizationId}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo`;
|
|
3552
3562
|
const response = await fetch(url, {
|
|
@@ -3556,12 +3566,16 @@ var fetchTenantsAndOrganizations = async (baseUrl, accessToken, organizationId)
|
|
|
3556
3566
|
});
|
|
3557
3567
|
if (!response.ok) {
|
|
3558
3568
|
if (response.status === 401) {
|
|
3559
|
-
throw new Error(
|
|
3569
|
+
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);
|
|
3560
3570
|
}
|
|
3561
3571
|
const errorText = await response.text();
|
|
3562
|
-
|
|
3572
|
+
const message = `Failed to get tenants and organizations: ${response.status} ${errorText}`;
|
|
3573
|
+
throw new Error(IDENTIFIER_STATUSES.has(response.status) ? `${message}. ${organizationHint(organizationId)}` : message);
|
|
3574
|
+
}
|
|
3575
|
+
const [parseError, data] = await catchError(response.json());
|
|
3576
|
+
if (parseError) {
|
|
3577
|
+
throw new Error(describeNonJsonResponse(organizationId, response, parseError));
|
|
3563
3578
|
}
|
|
3564
|
-
const data = await response.json();
|
|
3565
3579
|
return data;
|
|
3566
3580
|
};
|
|
3567
3581
|
|
|
@@ -4005,4 +4019,4 @@ export {
|
|
|
4005
4019
|
AUTH_CANCELLED_ERROR_CODE
|
|
4006
4020
|
};
|
|
4007
4021
|
|
|
4008
|
-
//# debugId=
|
|
4022
|
+
//# debugId=C655D07F97343A8C64756E2164756E21
|
|
@@ -12,6 +12,18 @@ export interface TenantsAndOrganizations {
|
|
|
12
12
|
tenants: Tenant[];
|
|
13
13
|
organization: Organization;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Fetch tenants and organizations from UiPath Cloud.
|
|
17
|
+
*
|
|
18
|
+
* @param organizationId - The organization segment of the portal URL. Pass the
|
|
19
|
+
* organization's name whenever it is known: the name is the segment that
|
|
20
|
+
* routes reliably, and it is never confused with the account GUID that
|
|
21
|
+
* licensing and analytics APIs take as `accountId`. The id works during login,
|
|
22
|
+
* where the token is always fresh — login has only the id at this point, the
|
|
23
|
+
* name is what this call returns — but it is not a like-for-like substitute
|
|
24
|
+
* later on: the portal has been seen answering `401` to the id (and to a
|
|
25
|
+
* case-variant of the name) on an aged-but-valid session that the exact name
|
|
26
|
+
* still resolves. So the id is a last-resort fallback, not an equal option.
|
|
27
|
+
*/
|
|
16
28
|
export declare const fetchTenantsAndOrganizations: (baseUrl: string, accessToken: string, organizationId: string) => Promise<TenantsAndOrganizations>;
|
|
17
29
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/auth",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.201.0-preview.
|
|
4
|
+
"version": "1.201.0-preview.122",
|
|
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": "
|
|
40
|
+
"gitHead": "6c56f56100be96231fccbaa59e99d64d94808d58"
|
|
41
41
|
}
|