@uipath/common 1.206.0-preview.296 → 1.206.0-preview.298

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.
@@ -0,0 +1,22 @@
1
+ /** Replace anything token-shaped in `text`. */
2
+ export declare function redactTokens(text: string): string;
3
+ /**
4
+ * Pull the reason out of a `WWW-Authenticate` challenge.
5
+ *
6
+ * Measured against alpha and staging: a real Studio Web or Agents runtime 401
7
+ * comes back with `content-length: 0` and puts the whole diagnostic in this
8
+ * header — `Bearer realm="…", error="invalid_token", error_description="The
9
+ * audience '(null)' is invalid"`. Without this the CLI has nothing to tell the
10
+ * user but the generated client's "Response returned an error code".
11
+ *
12
+ * Only the two RFC 6750 fields are taken. `realm` is deliberately dropped: it
13
+ * is an internal endpoint URL, it says nothing about why the call failed, and
14
+ * echoing routing metadata into user-facing errors is the pattern the security
15
+ * checklist warns about. `error` is a small fixed vocabulary; `error_description`
16
+ * is free text, so it goes through {@link redactTokens} and a length cap in
17
+ * case Identity ever quotes the presented credential back.
18
+ */
19
+ export declare function parseAuthChallenge(header?: string): {
20
+ error?: string;
21
+ description?: string;
22
+ };
@@ -1,3 +1,4 @@
1
+ export * from "./auth-challenge";
1
2
  export * from "./catch-error";
2
3
  export * from "./classified-failure";
3
4
  export * from "./command-examples";
@@ -20556,6 +20556,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
20556
20556
  exports.useColor = useColor;
20557
20557
  });
20558
20558
 
20559
+ // src/auth-challenge.ts
20560
+ var TOKEN_SHAPED = /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]*)?|\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi;
20561
+ function redactTokens(text) {
20562
+ return text.replace(TOKEN_SHAPED, "[REDACTED]");
20563
+ }
20564
+ var MAX_CHALLENGE_DESCRIPTION = 200;
20565
+ function parseAuthChallenge(header) {
20566
+ if (!header)
20567
+ return {};
20568
+ const code = /\berror="([^"]*)"/.exec(header)?.[1]?.trim();
20569
+ const raw = /\berror_description="([^"]*)"/.exec(header)?.[1]?.trim();
20570
+ const description = raw ? redactTokens(raw).slice(0, MAX_CHALLENGE_DESCRIPTION) : undefined;
20571
+ return {
20572
+ error: code || undefined,
20573
+ description: description || undefined
20574
+ };
20575
+ }
20559
20576
  // src/telemetry/telemetry-dimensions.ts
20560
20577
  var CLI_APPLICATION_NAME = "UiPath.Cli";
20561
20578
  var BaseDimensions = {
@@ -25256,6 +25273,7 @@ export {
25256
25273
  msToDuration,
25257
25274
  normalizeSkillName,
25258
25275
  notSupportedFailure,
25276
+ parseAuthChallenge,
25259
25277
  parseBoundedInt,
25260
25278
  parseHttpStatusFromMessage,
25261
25279
  parseLimit,
@@ -25271,6 +25289,7 @@ export {
25271
25289
  recordExitCode,
25272
25290
  recordHostExit,
25273
25291
  recordHttpCall,
25292
+ redactTokens,
25274
25293
  registerPackageMetadataOptions,
25275
25294
  resetExitCode,
25276
25295
  resetLoggerInstance,
@@ -25305,4 +25324,4 @@ export {
25305
25324
  withinProjectIdentityBudget
25306
25325
  };
25307
25326
 
25308
- //# debugId=0C3A52AD0A29848964756E2164756E21
25327
+ //# debugId=82FD8317CA85718664756E2164756E21
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./attachment-binding";
2
+ export * from "./auth-challenge";
2
3
  export * from "./body-validators";
3
4
  export * from "./catch-error";
4
5
  export * from "./classified-failure";
package/dist/index.js CHANGED
@@ -9021,6 +9021,23 @@ async function resolveAttachmentInputs(specs, upload) {
9021
9021
  return { name: p.name, path: p.path, reference };
9022
9022
  }));
9023
9023
  }
9024
+ // src/auth-challenge.ts
9025
+ var TOKEN_SHAPED = /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]*)?|\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi;
9026
+ function redactTokens(text) {
9027
+ return text.replace(TOKEN_SHAPED, "[REDACTED]");
9028
+ }
9029
+ var MAX_CHALLENGE_DESCRIPTION = 200;
9030
+ function parseAuthChallenge(header) {
9031
+ if (!header)
9032
+ return {};
9033
+ const code = /\berror="([^"]*)"/.exec(header)?.[1]?.trim();
9034
+ const raw = /\berror_description="([^"]*)"/.exec(header)?.[1]?.trim();
9035
+ const description = raw ? redactTokens(raw).slice(0, MAX_CHALLENGE_DESCRIPTION) : undefined;
9036
+ return {
9037
+ error: code || undefined,
9038
+ description: description || undefined
9039
+ };
9040
+ }
9024
9041
  // src/body-validators.ts
9025
9042
  function runValidators(input, validators) {
9026
9043
  for (const v of validators) {
@@ -15452,6 +15469,7 @@ export {
15452
15469
  normalizeSkillName,
15453
15470
  notSupportedFailure,
15454
15471
  parseAttachmentSpec,
15472
+ parseAuthChallenge,
15455
15473
  parseBoundedInt,
15456
15474
  parseHttpStatusFromMessage,
15457
15475
  parseInboundTraceparent,
@@ -15483,6 +15501,7 @@ export {
15483
15501
  redactMessage,
15484
15502
  redactProperties,
15485
15503
  redactProperty,
15504
+ redactTokens,
15486
15505
  registerPackageMetadataOptions,
15487
15506
  releaseClaimedSpoolFile,
15488
15507
  releaseSuppliedArgumentValues,
@@ -15552,4 +15571,4 @@ export {
15552
15571
  writeTelemetrySpoolFile
15553
15572
  };
15554
15573
 
15555
- //# debugId=9DC1DD9A8955F55564756E2164756E21
15574
+ //# debugId=B2E7D391B7CC585C64756E2164756E21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/common",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.296",
5
+ "version": "1.206.0-preview.298",
6
6
  "description": "Common infrastructure needed by uip tools.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -102,5 +102,5 @@
102
102
  "mihaigirleanu",
103
103
  "vlad-uipath"
104
104
  ],
105
- "gitHead": "b816f3b1d711f0888be774af87a58536780af5c2"
105
+ "gitHead": "a0ed1d051971fa12165c56d8b74d0be5d7a25d41"
106
106
  }