@uipath/packager-remote-agent-browser 1.207.0-preview.309 → 1.207.0-preview.314

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.
@@ -41,6 +41,8 @@ export declare const en: {
41
41
  readonly createAttachmentFailed: "Failed to create input arguments attachment ({status}): {errorText}";
42
42
  readonly attachmentResponseMalformed: "Attachment creation response did not include an id and blob URI";
43
43
  readonly uploadInputArgumentsFailed: "Failed to upload input arguments file ({status}): {statusText}";
44
+ readonly blobAccessTokenMissing: "Orchestrator requires credentials for the file on {host}, and the connection has no access token.";
45
+ readonly blobUriNotSameOrigin: "Orchestrator requires credentials for the file at {host}, but its URI has no path this page can request from Orchestrator, so the credentials were not sent.";
44
46
  };
45
47
  };
46
48
  };
package/dist/index.js CHANGED
@@ -76,7 +76,9 @@ var en = {
76
76
  bundleOperationMismatch: "Cannot mix {sessionOperation} and {entryOperation} in the same context",
77
77
  createAttachmentFailed: "Failed to create input arguments attachment ({status}): {errorText}",
78
78
  attachmentResponseMalformed: "Attachment creation response did not include an id and blob URI",
79
- uploadInputArgumentsFailed: "Failed to upload input arguments file ({status}): {statusText}"
79
+ uploadInputArgumentsFailed: "Failed to upload input arguments file ({status}): {statusText}",
80
+ blobAccessTokenMissing: "Orchestrator requires credentials for the file on {host}, and the connection has no access token.",
81
+ blobUriNotSameOrigin: "Orchestrator requires credentials for the file at {host}, but its URI has no path this page can request from Orchestrator, so the credentials were not sent."
80
82
  }
81
83
  }
82
84
  };
@@ -582,15 +584,86 @@ import {
582
584
  ToolResult as ToolResult2,
583
585
  toProjectCleanupInfoFromRemote,
584
586
  toRelativeUrl as toRelativeUrl2,
585
- translate as translate3
587
+ translate as translate4
586
588
  } from "@uipath/solutionpackager-tool-core";
587
589
 
590
+ // src/orchestrator-blob.ts
591
+ import {
592
+ translate
593
+ } from "@uipath/solutionpackager-tool-core";
594
+ function blobRequest(access, connection) {
595
+ const url = blobRequestUrl(access);
596
+ return {
597
+ url,
598
+ init: {
599
+ headers: blobRequestHeaders(access, connection),
600
+ redirect: access.RequiresAuth ? "error" : "follow"
601
+ }
602
+ };
603
+ }
604
+ function blobRequestUrl(access) {
605
+ if (!access.RequiresAuth) {
606
+ return access.Uri;
607
+ }
608
+ const path = sameOriginPath(access.Uri);
609
+ if (path === undefined) {
610
+ throw new Error(translate.t("remoteAgentBrowser.errors.blobUriNotSameOrigin", {
611
+ host: hostOf(access.Uri)
612
+ }));
613
+ }
614
+ return path;
615
+ }
616
+ function sameOriginPath(uri) {
617
+ let url;
618
+ try {
619
+ url = new URL(uri);
620
+ } catch {
621
+ return;
622
+ }
623
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
624
+ return;
625
+ }
626
+ const path = url.pathname + url.search;
627
+ return path.startsWith("//") ? undefined : path;
628
+ }
629
+ function blobRequestHeaders(access, connection) {
630
+ const headers = {};
631
+ const { Keys, Values } = access.Headers ?? {};
632
+ if (Keys && Values) {
633
+ for (let i = 0;i < Keys.length; i++) {
634
+ headers[Keys[i]] = Values[i];
635
+ }
636
+ }
637
+ if (access.RequiresAuth) {
638
+ if (!connection.accessToken) {
639
+ throw new Error(translate.t("remoteAgentBrowser.errors.blobAccessTokenMissing", {
640
+ host: hostOf(access.Uri)
641
+ }));
642
+ }
643
+ headers.Authorization = `Bearer ${connection.accessToken}`;
644
+ if (connection.folderId) {
645
+ headers["X-UIPATH-OrganizationUnitId"] = connection.folderId;
646
+ }
647
+ if (connection.tenantId) {
648
+ headers["x-uipath-tenantid"] = connection.tenantId;
649
+ }
650
+ }
651
+ return headers;
652
+ }
653
+ function hostOf(uri) {
654
+ try {
655
+ return new URL(uri).host;
656
+ } catch {
657
+ return uri;
658
+ }
659
+ }
660
+
588
661
  // src/pack-result-processor.ts
589
662
  import {
590
663
  ToolErrorCodes,
591
664
  ToolResult,
592
665
  toRelativeUrl,
593
- translate,
666
+ translate as translate2,
594
667
  ZipService
595
668
  } from "@uipath/solutionpackager-tool-core";
596
669
  var DefaultArchiveName = "rpa-packages.zip";
@@ -610,16 +683,16 @@ class PackResultProcessor {
610
683
  const tempDir = await this.fileSystem.getTempDir();
611
684
  const extractPath = `${tempDir}/pack-result-${context.id}`;
612
685
  try {
613
- this.logger?.info(translate.t("remoteAgentBrowser.info.downloadingArchive", {
686
+ this.logger?.info(translate2.t("remoteAgentBrowser.info.downloadingArchive", {
614
687
  bucketId
615
688
  }));
616
689
  const zipData = await this.downloadArchiveAsync(bucketId, archiveName || DefaultArchiveName, connection);
617
- this.logger?.info(translate.t("remoteAgentBrowser.info.extractingArchive", {
690
+ this.logger?.info(translate2.t("remoteAgentBrowser.info.extractingArchive", {
618
691
  size: zipData.length,
619
692
  path: extractPath
620
693
  }));
621
694
  await this.zipService.extractAsync(zipData, extractPath);
622
- this.logger?.info(translate.t("remoteAgentBrowser.info.distributingPackages", {
695
+ this.logger?.info(translate2.t("remoteAgentBrowser.info.distributingPackages", {
623
696
  count: projects.size
624
697
  }));
625
698
  await this.distributePackages(extractPath, projects, context, results);
@@ -631,7 +704,7 @@ class PackResultProcessor {
631
704
  }
632
705
  }
633
706
  } finally {
634
- this.logger?.info(translate.t("remoteAgentBrowser.info.cleaningUpTempDir", {
707
+ this.logger?.info(translate2.t("remoteAgentBrowser.info.cleaningUpTempDir", {
635
708
  path: extractPath
636
709
  }));
637
710
  await this.fileSystem.rm(extractPath).catch(() => {});
@@ -641,7 +714,7 @@ class PackResultProcessor {
641
714
  }
642
715
  async downloadArchiveAsync(bucketId, archiveName, connection) {
643
716
  const blobAccess = await this.getReadUriAsync(bucketId, archiveName, connection);
644
- return await this.downloadBlobAsync(blobAccess);
717
+ return await this.downloadBlobAsync(blobAccess, connection);
645
718
  }
646
719
  async deleteBucketAsync(bucketId, connection) {
647
720
  try {
@@ -650,7 +723,7 @@ class PackResultProcessor {
650
723
  }
651
724
  const baseUrl = toRelativeUrl(connection.cloudUrl);
652
725
  const url = `${baseUrl}/orchestrator_/odata/Buckets(${bucketId})`;
653
- this.logger?.info(translate.t("remoteAgentBrowser.info.deletingBucket", {
726
+ this.logger?.info(translate2.t("remoteAgentBrowser.info.deletingBucket", {
654
727
  bucketId
655
728
  }));
656
729
  const response = await fetch(url, {
@@ -661,11 +734,11 @@ class PackResultProcessor {
661
734
  }
662
735
  });
663
736
  if (!response.ok) {
664
- throw new Error(translate.t("remoteAgentBrowser.errors.deleteBucketFailed", { statusText: response.statusText }));
737
+ throw new Error(translate2.t("remoteAgentBrowser.errors.deleteBucketFailed", { statusText: response.statusText }));
665
738
  }
666
739
  } catch (error) {
667
740
  const message = error instanceof Error ? error.message : String(error);
668
- this.logger?.warn(translate.t("remoteAgentBrowser.errors.cleanupBucketFailed", {
741
+ this.logger?.warn(translate2.t("remoteAgentBrowser.errors.cleanupBucketFailed", {
669
742
  bucketId,
670
743
  message
671
744
  }));
@@ -683,34 +756,29 @@ class PackResultProcessor {
683
756
  });
684
757
  if (!response.ok) {
685
758
  const errorText = await response.text();
686
- throw new Error(translate.t("remoteAgentBrowser.errors.getBucketUriFailed", {
759
+ throw new Error(translate2.t("remoteAgentBrowser.errors.getBucketUriFailed", {
687
760
  status: response.status,
688
761
  errorText
689
762
  }));
690
763
  }
691
764
  return await response.json();
692
765
  }
693
- async downloadBlobAsync(blobAccess) {
694
- const headers = {};
695
- if (blobAccess.Headers) {
696
- for (const [key, value] of Object.entries(blobAccess.Headers)) {
697
- headers[key] = value;
698
- }
699
- }
766
+ async downloadBlobAsync(blobAccess, connection) {
767
+ const { url, init } = blobRequest(blobAccess, connection);
700
768
  let response;
701
769
  try {
702
- response = await fetch(blobAccess.Uri, {
703
- method: blobAccess.Verb || "GET",
704
- headers
770
+ response = await fetch(url, {
771
+ ...init,
772
+ method: blobAccess.Verb || "GET"
705
773
  });
706
774
  } catch (error) {
707
- throw new Error(translate.t("remoteAgentBrowser.errors.downloadArchiveUnreachable", {
775
+ throw new Error(translate2.t("remoteAgentBrowser.errors.downloadArchiveUnreachable", {
708
776
  host: hostOf(blobAccess.Uri),
709
777
  message: error instanceof Error ? error.message : String(error)
710
778
  }));
711
779
  }
712
780
  if (!response.ok) {
713
- throw new Error(translate.t("remoteAgentBrowser.errors.downloadArchiveFailed", {
781
+ throw new Error(translate2.t("remoteAgentBrowser.errors.downloadArchiveFailed", {
714
782
  status: response.status,
715
783
  statusText: response.statusText
716
784
  }));
@@ -722,7 +790,7 @@ class PackResultProcessor {
722
790
  for (const [projectPath, entry] of projects) {
723
791
  const project = context.projects.find((p) => p.ProjectPath === projectPath);
724
792
  if (!project) {
725
- results.set(projectPath, ToolResult.error("PackResultError", translate.t("remoteAgentBrowser.errors.noMatchingProject", { projectPath })));
793
+ results.set(projectPath, ToolResult.error("PackResultError", translate2.t("remoteAgentBrowser.errors.noMatchingProject", { projectPath })));
726
794
  continue;
727
795
  }
728
796
  const designId = project.Id;
@@ -731,7 +799,7 @@ class PackResultProcessor {
731
799
  try {
732
800
  const exists = await this.fileSystem.exists(projectFilesDir);
733
801
  if (!exists) {
734
- results.set(projectPath, ToolResult.error("PackResultError", translate.t("remoteAgentBrowser.errors.noPackageFromAgent", {
802
+ results.set(projectPath, ToolResult.error("PackResultError", translate2.t("remoteAgentBrowser.errors.noPackageFromAgent", {
735
803
  project: project.ProjectRelativePath,
736
804
  projectType: project.Type,
737
805
  designId
@@ -741,7 +809,7 @@ class PackResultProcessor {
741
809
  const files = await this.fileSystem.readdir(projectFilesDir);
742
810
  const outputFiles = [];
743
811
  await this.fileSystem.mkdir(outputPath);
744
- this.logger?.info(translate.t("remoteAgentBrowser.info.copyingFiles", {
812
+ this.logger?.info(translate2.t("remoteAgentBrowser.info.copyingFiles", {
745
813
  count: files.length,
746
814
  designId,
747
815
  path: outputPath
@@ -758,18 +826,11 @@ class PackResultProcessor {
758
826
  results.set(projectPath, new ToolResult(ToolErrorCodes.Success, undefined, outputFiles));
759
827
  } catch (error) {
760
828
  const message = error instanceof Error ? error.message : String(error);
761
- results.set(projectPath, ToolResult.error("PackResultError", translate.t("remoteAgentBrowser.errors.distributePackagesFailed", { designId, message })));
829
+ results.set(projectPath, ToolResult.error("PackResultError", translate2.t("remoteAgentBrowser.errors.distributePackagesFailed", { designId, message })));
762
830
  }
763
831
  }
764
832
  }
765
833
  }
766
- function hostOf(uri) {
767
- try {
768
- return new URL(uri).host;
769
- } catch {
770
- return uri;
771
- }
772
- }
773
834
 
774
835
  // src/packager-hub-connection.ts
775
836
  import {
@@ -779,7 +840,7 @@ import {
779
840
  } from "@microsoft/signalr";
780
841
  import {
781
842
  LogMessage,
782
- translate as translate2
843
+ translate as translate3
783
844
  } from "@uipath/solutionpackager-tool-core";
784
845
  class PackagerHubConnection {
785
846
  logger;
@@ -816,7 +877,7 @@ class PackagerHubConnection {
816
877
  this.hubConnection?.onclose((error) => {
817
878
  this.logger?.info(`[PackagerHub] onclose fired. error=${error?.message ?? "none"}, hasReject=${!!this.completionReject}, hasResolve=${!!this.completionResolve}`);
818
879
  if (this.completionReject) {
819
- this.completionReject(error ?? new Error(translate2.t("remoteAgentBrowser.errors.hubConnectionClosed")));
880
+ this.completionReject(error ?? new Error(translate3.t("remoteAgentBrowser.errors.hubConnectionClosed")));
820
881
  this.completionResolve = null;
821
882
  this.completionReject = null;
822
883
  }
@@ -844,12 +905,12 @@ class PackagerHubConnection {
844
905
  this.onLogMessage(jsonCommand);
845
906
  });
846
907
  this.hubConnection.on("SetExecutionStarted" /* SetExecutionStarted */, (_jsonCommand) => {
847
- this.logger?.info(translate2.t("remoteAgentBrowser.info.remoteAgentStartedExecution"));
908
+ this.logger?.info(translate3.t("remoteAgentBrowser.info.remoteAgentStartedExecution"));
848
909
  });
849
910
  this.hubConnection.on("PeerDisconnected" /* PeerDisconnected */, () => {
850
911
  this.logger?.info(`[PackagerHub] PeerDisconnected received. hasReject=${!!this.completionReject}`);
851
912
  if (this.completionReject) {
852
- this.completionReject(new Error(translate2.t("remoteAgentBrowser.errors.packAgentDisconnected")));
913
+ this.completionReject(new Error(translate3.t("remoteAgentBrowser.errors.packAgentDisconnected")));
853
914
  this.completionResolve = null;
854
915
  this.completionReject = null;
855
916
  }
@@ -980,13 +1041,13 @@ class RemoteAgentBundleExecutor {
980
1041
  }
981
1042
  checkJoin(session, operation, projectPath) {
982
1043
  if (session.operation !== operation) {
983
- return ToolResult2.error("BundleOperationMismatch", translate3.t("remoteAgentBrowser.errors.bundleOperationMismatch", {
1044
+ return ToolResult2.error("BundleOperationMismatch", translate4.t("remoteAgentBrowser.errors.bundleOperationMismatch", {
984
1045
  sessionOperation: session.operation,
985
1046
  entryOperation: operation
986
1047
  }));
987
1048
  }
988
1049
  if (!session.remoteProjects.some((p) => p.ProjectPath === projectPath)) {
989
- return ToolResult2.error("PackResultError", translate3.t("remoteAgentBrowser.errors.noMatchingProject", {
1050
+ return ToolResult2.error("PackResultError", translate4.t("remoteAgentBrowser.errors.noMatchingProject", {
990
1051
  projectPath
991
1052
  }));
992
1053
  }
@@ -1027,7 +1088,7 @@ class RemoteAgentBundleExecutor {
1027
1088
  session.timeout = setTimeout(() => {
1028
1089
  if (receivedCount(session) < session.remoteProjects.length) {
1029
1090
  context.logger?.error(`[BundleExecutor] Session timed out after ${RemoteAgentBundleExecutor.SESSION_TIMEOUT_MS}ms: ` + `received ${receivedCount(session)}/${session.remoteProjects.length} projects`);
1030
- this.resolveAll(session, ToolResult2.error("SessionTimeoutError", translate3.t("remoteAgentBrowser.errors.sessionTimeout", {
1091
+ this.resolveAll(session, ToolResult2.error("SessionTimeoutError", translate4.t("remoteAgentBrowser.errors.sessionTimeout", {
1031
1092
  received: receivedCount(session),
1032
1093
  expected: session.remoteProjects.length
1033
1094
  })));
@@ -1039,7 +1100,7 @@ class RemoteAgentBundleExecutor {
1039
1100
  return session;
1040
1101
  }
1041
1102
  async runAgentAsync(session, context) {
1042
- context.logger?.info(translate3.t("remoteAgentBrowser.info.startingRemoteAgent", {
1103
+ context.logger?.info(translate4.t("remoteAgentBrowser.info.startingRemoteAgent", {
1043
1104
  operation: session.operation,
1044
1105
  count: session.entries.size,
1045
1106
  paths: [...session.entries.keys()].join(", ")
@@ -1047,13 +1108,13 @@ class RemoteAgentBundleExecutor {
1047
1108
  const connection = context.connection;
1048
1109
  context.logger?.info(`[BundleExecutor] connection info: cloudUrl=${connection?.cloudUrl ?? "MISSING"}, hasToken=${!!connection?.accessToken}, folderId=${connection?.folderId ?? "MISSING"}`);
1049
1110
  if (!connection?.cloudUrl || !connection.accessToken || !connection.folderId) {
1050
- this.resolveAll(session, ToolResult2.error("ConnectionError", translate3.t("remoteAgentBrowser.errors.missingConnectionInfo")));
1111
+ this.resolveAll(session, ToolResult2.error("ConnectionError", translate4.t("remoteAgentBrowser.errors.missingConnectionInfo")));
1051
1112
  return;
1052
1113
  }
1053
1114
  const sessionId = crypto.randomUUID();
1054
1115
  const hubConnection = await this.connectToHubAsync(connection, sessionId, context.logger);
1055
1116
  if (!hubConnection) {
1056
- this.resolveAll(session, ToolResult2.error("SignalRConnectionError", translate3.t("remoteAgentBrowser.errors.signalRConnectionFailed")));
1117
+ this.resolveAll(session, ToolResult2.error("SignalRConnectionError", translate4.t("remoteAgentBrowser.errors.signalRConnectionFailed")));
1057
1118
  return;
1058
1119
  }
1059
1120
  const stopWatching = new AbortController;
@@ -1114,7 +1175,7 @@ class RemoteAgentBundleExecutor {
1114
1175
  }
1115
1176
  }
1116
1177
  await this.stopPendingJobAsync(job?.Id, jobKey, orchestratorUrl, connection, logger);
1117
- throw new Error(translate3.t("remoteAgentBrowser.errors.jobStartTimeout", {
1178
+ throw new Error(translate4.t("remoteAgentBrowser.errors.jobStartTimeout", {
1118
1179
  jobKey,
1119
1180
  minutes: RemoteAgentBundleExecutor.JOB_START_TIMEOUT_MS / 60000
1120
1181
  }));
@@ -1146,7 +1207,7 @@ class RemoteAgentBundleExecutor {
1146
1207
  async connectToHubAsync(connection, sessionId, logger) {
1147
1208
  const relativeBase = toRelativeUrl2(connection.cloudUrl);
1148
1209
  const hubUrl = `${relativeBase}/orchestrator_/signalr/robotdebug?sessionId=${sessionId}`;
1149
- logger?.info(translate3.t("remoteAgentBrowser.info.connectingToHub", {
1210
+ logger?.info(translate4.t("remoteAgentBrowser.info.connectingToHub", {
1150
1211
  url: hubUrl
1151
1212
  }));
1152
1213
  const hubConnection = new PackagerHubConnection(logger);
@@ -1155,7 +1216,7 @@ class RemoteAgentBundleExecutor {
1155
1216
  return hubConnection;
1156
1217
  } catch (error) {
1157
1218
  const message = error instanceof Error ? error.message : String(error);
1158
- logger?.error(translate3.t("remoteAgentBrowser.errors.hubConnectionFailed", {
1219
+ logger?.error(translate4.t("remoteAgentBrowser.errors.hubConnectionFailed", {
1159
1220
  url: hubUrl,
1160
1221
  message
1161
1222
  }));
@@ -1164,7 +1225,7 @@ class RemoteAgentBundleExecutor {
1164
1225
  }
1165
1226
  async handleAgentResultAsync(result, session, context) {
1166
1227
  if (result.errorCode !== 0 || result.status !== 0 /* Succeeded */) {
1167
- this.resolveAll(session, ToolResult2.error(`${session.operation}AgentError`, result.message ?? translate3.t("remoteAgentBrowser.errors.agentFailed", {
1228
+ this.resolveAll(session, ToolResult2.error(`${session.operation}AgentError`, result.message ?? translate4.t("remoteAgentBrowser.errors.agentFailed", {
1168
1229
  operation: session.operation,
1169
1230
  status: result.status,
1170
1231
  errorCode: result.errorCode
@@ -1200,7 +1261,7 @@ class RemoteAgentBundleExecutor {
1200
1261
  }
1201
1262
  async handlePackBucketAsync(result, session, context) {
1202
1263
  if (result.bucketId == null) {
1203
- this.resolveAll(session, ToolResult2.error("PackAgentError", translate3.t("remoteAgentBrowser.errors.packSucceededNoBucket")));
1264
+ this.resolveAll(session, ToolResult2.error("PackAgentError", translate4.t("remoteAgentBrowser.errors.packSucceededNoBucket")));
1204
1265
  return;
1205
1266
  }
1206
1267
  const packEntries = new Map;
@@ -1213,7 +1274,7 @@ class RemoteAgentBundleExecutor {
1213
1274
  const perProjectResults = await resultProcessor.processAsync(result.bucketId, packEntries, context, result.archiveName);
1214
1275
  for (const [projectPath, entry] of session.entries) {
1215
1276
  const projectResult = perProjectResults.get(projectPath);
1216
- entry.resolve(projectResult ?? ToolResult2.error("PackResultError", translate3.t("remoteAgentBrowser.errors.noResultForProject")));
1277
+ entry.resolve(projectResult ?? ToolResult2.error("PackResultError", translate4.t("remoteAgentBrowser.errors.noResultForProject")));
1217
1278
  }
1218
1279
  }
1219
1280
  async sendBeginSessionAsync(session, context, connection, sessionId) {
@@ -1316,7 +1377,7 @@ class RemoteAgentBundleExecutor {
1316
1377
  jobType: "PublishStudioProject"
1317
1378
  };
1318
1379
  if (inputArguments.length > RemoteAgentBundleExecutor.MAX_INLINE_INPUT_ARGUMENTS_LENGTH) {
1319
- context.logger?.info(translate3.t("remoteAgentBrowser.info.offloadingInputArguments", { length: inputArguments.length }));
1380
+ context.logger?.info(translate4.t("remoteAgentBrowser.info.offloadingInputArguments", { length: inputArguments.length }));
1320
1381
  body.inputFile = await this.uploadInputArgumentsFileAsync(inputArguments, connection, context.logger);
1321
1382
  } else {
1322
1383
  body.inputArguments = inputArguments;
@@ -1336,7 +1397,7 @@ class RemoteAgentBundleExecutor {
1336
1397
  });
1337
1398
  if (!response.ok) {
1338
1399
  const errorText = await response.text();
1339
- throw new Error(translate3.t("remoteAgentBrowser.errors.beginSessionFailed", {
1400
+ throw new Error(translate4.t("remoteAgentBrowser.errors.beginSessionFailed", {
1340
1401
  status: response.status,
1341
1402
  errorText
1342
1403
  }));
@@ -1364,24 +1425,32 @@ class RemoteAgentBundleExecutor {
1364
1425
  });
1365
1426
  if (!createResponse.ok) {
1366
1427
  const errorText = await createResponse.text();
1367
- throw new Error(translate3.t("remoteAgentBrowser.errors.createAttachmentFailed", { status: createResponse.status, errorText }));
1428
+ throw new Error(translate4.t("remoteAgentBrowser.errors.createAttachmentFailed", { status: createResponse.status, errorText }));
1368
1429
  }
1369
1430
  const attachment = await createResponse.json();
1370
1431
  const attachmentId = attachment.Id ?? attachment.id ?? "";
1371
- const writeUri = attachment.BlobFileAccess?.Uri ?? attachment.blobFileAccess?.Uri;
1432
+ const blobAccess = attachment.BlobFileAccess ?? attachment.blobFileAccess;
1433
+ const writeUri = blobAccess?.Uri;
1372
1434
  if (!attachmentId || !writeUri) {
1373
- throw new Error(translate3.t("remoteAgentBrowser.errors.attachmentResponseMalformed"));
1374
- }
1375
- const uploadResponse = await fetch(writeUri, {
1435
+ throw new Error(translate4.t("remoteAgentBrowser.errors.attachmentResponseMalformed"));
1436
+ }
1437
+ const { url, init } = blobRequest({
1438
+ Uri: writeUri,
1439
+ Headers: blobAccess?.Headers,
1440
+ RequiresAuth: blobAccess?.RequiresAuth
1441
+ }, connection);
1442
+ const uploadResponse = await fetch(url, {
1443
+ ...init,
1376
1444
  method: "PUT",
1377
1445
  headers: {
1446
+ ...init.headers,
1378
1447
  "Content-Type": "application/octet-stream",
1379
1448
  "x-ms-blob-type": "BlockBlob"
1380
1449
  },
1381
1450
  body: inputArguments
1382
1451
  });
1383
1452
  if (!uploadResponse.ok) {
1384
- throw new Error(translate3.t("remoteAgentBrowser.errors.uploadInputArgumentsFailed", {
1453
+ throw new Error(translate4.t("remoteAgentBrowser.errors.uploadInputArgumentsFailed", {
1385
1454
  status: uploadResponse.status,
1386
1455
  statusText: uploadResponse.statusText
1387
1456
  }));
@@ -1520,4 +1589,4 @@ export {
1520
1589
  getSharedRemoteAgentBundleExecutor
1521
1590
  };
1522
1591
 
1523
- //# debugId=1DB90C56CD11E01764756E2164756E21
1592
+ //# debugId=A1D2971F4A3B71B864756E2164756E21
@@ -0,0 +1,31 @@
1
+ import { type ConnectionInfo } from "@uipath/solutionpackager-tool-core";
2
+ /** Orchestrator's `BlobFileAccessDto` as its REST API returns it. */
3
+ export interface BlobFileAccess {
4
+ Uri: string;
5
+ Verb?: string;
6
+ Headers?: {
7
+ Keys?: string[];
8
+ Values?: string[];
9
+ };
10
+ RequiresAuth?: boolean;
11
+ }
12
+ /** Where and how to send the request for a blob URI Orchestrator handed out. */
13
+ export interface BlobRequest {
14
+ url: string;
15
+ init: {
16
+ headers: Record<string, string>;
17
+ redirect: "error" | "follow";
18
+ };
19
+ }
20
+ /**
21
+ * The request for a blob URI Orchestrator handed out: its URL and the `fetch`
22
+ * init its credentials decide, built together so the token never goes with a
23
+ * URL that has not been checked.
24
+ *
25
+ * A request carrying the token and folder never follows a redirect, since the
26
+ * browser would keep the folder and tenant headers on any hop. Orchestrator
27
+ * serves such a blob itself, so a redirect is an error.
28
+ */
29
+ export declare function blobRequest(access: Pick<BlobFileAccess, "Uri" | "Headers" | "RequiresAuth">, connection: ConnectionInfo): BlobRequest;
30
+ /** The host of `uri`, or the raw value when it does not parse. */
31
+ export declare function hostOf(uri: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/packager-remote-agent-browser",
3
- "version": "1.207.0-preview.309",
3
+ "version": "1.207.0-preview.314",
4
4
  "description": "UiPath Remote Agent bundling for browser packager tools",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,5 +24,5 @@
24
24
  "@uipath/solutionpackager-tool-core": "1.207.0",
25
25
  "@microsoft/signalr": ">=7 <11"
26
26
  },
27
- "gitHead": "774a444bdf3a34422d4b1425da0935653e2e5ca9"
27
+ "gitHead": "9aee7acc666f8511e30cd28417fa5f24d5ae716c"
28
28
  }