@crestapps/ai-chat-ui 2.0.0-preview.259 → 2.0.0-preview.260

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/ai-chat.js CHANGED
@@ -19,6 +19,7 @@
19
19
  var defaultConfig = {
20
20
  generatedImageAltText: "Generated Image",
21
21
  generatedImageMaxWidth: 400,
22
+ allowedImageHosts: [],
22
23
  downloadImageTitle: "Download image",
23
24
  downloadChartTitle: "Download chart as image",
24
25
  downloadChartButtonText: "Download",
@@ -480,6 +481,7 @@
480
481
  renderer.image = function(data) {
481
482
  const src = sanitizeUrl(data.href);
482
483
  if (!src) return "";
484
+ if (!window.CoreAIImages.isAllowedSource(src, { allowedHosts: defaultConfig.allowedImageHosts })) return window.CoreAIImages.linkHtml(src, data.text);
483
485
  const alt = data.text || defaultConfig.generatedImageAltText;
484
486
  return `<span class="generated-image-container">
485
487
  <img src="${src}" alt="${alt}" class="img-thumbnail" style="max-width: ${defaultConfig.generatedImageMaxWidth}px; height: auto;" />
@@ -603,10 +605,10 @@
603
605
  _pendingCharts = [];
604
606
  const html = styleMarkdownTables(marked.parse(content, { renderer }));
605
607
  message._pendingCharts = _pendingCharts.length > 0 ? [..._pendingCharts] : [];
606
- const sanitizedHtml = DOMPurify.sanitize(html, {
608
+ const sanitizedHtml = window.CoreAIImages.sanitize(DOMPurify, html, {
607
609
  ADD_TAGS: ["canvas"],
608
610
  ADD_ATTR: ["target"]
609
- });
611
+ }, { allowedHosts: defaultConfig.allowedImageHosts });
610
612
  return window.CoreAIChatImageCarousel ? window.CoreAIChatImageCarousel.stackAdjacentImages(sanitizedHtml) : sanitizedHtml;
611
613
  }
612
614
  function compactObject(source) {
@@ -817,6 +819,7 @@
817
819
  for (var i = 0; i < filesToUpload.length; i++) formData.append("files", filesToUpload[i]);
818
820
  var response = await fetch(config.uploadDocumentUrl, {
819
821
  method: "POST",
822
+ headers: window.CoreAIAntiforgery.headers(config, void 0, config.uploadDocumentUrl),
820
823
  body: formData
821
824
  });
822
825
  if (!response.ok) {
@@ -866,7 +869,7 @@
866
869
  var sessionId = this.getSessionId();
867
870
  var response = await fetch(config.removeDocumentUrl, {
868
871
  method: "POST",
869
- headers: { "Content-Type": "application/json" },
872
+ headers: window.CoreAIAntiforgery.headers(config, { "Content-Type": "application/json" }, config.removeDocumentUrl),
870
873
  body: JSON.stringify({
871
874
  itemId: sessionId,
872
875
  documentId: doc.documentId