@uipath/auth 0.1.11 → 0.2.0
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.js +32 -14
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10019,7 +10019,8 @@ var getBaseHtml = ({ title, message, type: type2 }) => {
|
|
|
10019
10019
|
// src/server.ts
|
|
10020
10020
|
var startServer = async ({
|
|
10021
10021
|
redirectUri,
|
|
10022
|
-
timeoutMs = DEFAULT_AUTH_TIMEOUT_MS
|
|
10022
|
+
timeoutMs = DEFAULT_AUTH_TIMEOUT_MS,
|
|
10023
|
+
onListening
|
|
10023
10024
|
}) => {
|
|
10024
10025
|
let http;
|
|
10025
10026
|
try {
|
|
@@ -10089,6 +10090,13 @@ var startServer = async ({
|
|
|
10089
10090
|
});
|
|
10090
10091
|
server.listen(redirectUri.port, () => {
|
|
10091
10092
|
logger.info("Waiting for authentication callback on port:", redirectUri.port);
|
|
10093
|
+
if (onListening) {
|
|
10094
|
+
Promise.resolve(onListening()).catch((err) => {
|
|
10095
|
+
server.close();
|
|
10096
|
+
clearTimeout(timeoutHandle);
|
|
10097
|
+
reject(err);
|
|
10098
|
+
});
|
|
10099
|
+
}
|
|
10092
10100
|
});
|
|
10093
10101
|
const timeoutHandle = setTimeout(() => {
|
|
10094
10102
|
server.close();
|
|
@@ -10111,24 +10119,34 @@ __export(exports_node_strategy, {
|
|
|
10111
10119
|
|
|
10112
10120
|
class NodeAuthStrategy {
|
|
10113
10121
|
async execute(url2, redirectUri) {
|
|
10114
|
-
logger.info("Opening browser for authentication...");
|
|
10115
|
-
logger.info(`If browser doesn't open, visit: ${url2}`);
|
|
10116
10122
|
const fs7 = getFileSystem();
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
+
const callbackUrl = await startServer({
|
|
10124
|
+
redirectUri,
|
|
10125
|
+
onListening: async () => {
|
|
10126
|
+
let safeUrl = "";
|
|
10127
|
+
for (const ch of url2) {
|
|
10128
|
+
const c = ch.charCodeAt(0);
|
|
10129
|
+
if (c > 31 && (c < 128 || c > 159))
|
|
10130
|
+
safeUrl += ch;
|
|
10131
|
+
}
|
|
10132
|
+
logger.info("Opening browser for authentication...");
|
|
10133
|
+
logger.info(`If browser doesn't open, visit: ${safeUrl}`);
|
|
10134
|
+
const [openError] = await catchError(fs7.utils.open(url2));
|
|
10135
|
+
if (!openError)
|
|
10136
|
+
return;
|
|
10137
|
+
const isSpawnError = "code" in openError && openError.code === "ENOENT";
|
|
10138
|
+
if (isSpawnError) {
|
|
10139
|
+
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:
|
|
10123
10140
|
|
|
10124
10141
|
` + ` uip login --client-id <id> --client-secret <secret> -t <tenant>
|
|
10125
10142
|
|
|
10126
|
-
` + "Or install a browser opener for your OS (e.g. xdg-utils on Linux).", { cause:
|
|
10143
|
+
` + "Or install a browser opener for your OS (e.g. xdg-utils on Linux).", { cause: openError });
|
|
10144
|
+
}
|
|
10145
|
+
throw new Error("Could not open the browser automatically. " + `Visit this URL to authenticate:
|
|
10146
|
+
|
|
10147
|
+
${safeUrl}
|
|
10148
|
+
`, { cause: openError });
|
|
10127
10149
|
}
|
|
10128
|
-
throw err;
|
|
10129
|
-
}
|
|
10130
|
-
const callbackUrl = await startServer({
|
|
10131
|
-
redirectUri
|
|
10132
10150
|
});
|
|
10133
10151
|
const code = callbackUrl.searchParams.get("code");
|
|
10134
10152
|
if (!code) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/UiPath/cli.git",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^25.5.0",
|
|
32
|
-
"@uipath/common": "0.
|
|
33
|
-
"@uipath/filesystem": "0.
|
|
32
|
+
"@uipath/common": "0.2.0",
|
|
33
|
+
"@uipath/filesystem": "0.2.0",
|
|
34
34
|
"openid-client": "^6.8.2",
|
|
35
35
|
"typescript": "^5",
|
|
36
36
|
"zod": "^4.3.6"
|