open-chat-studio-widget 0.5.2 → 0.5.3

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.
Files changed (27) hide show
  1. package/dist/cjs/{index-Ctja7z-R.js → index-D8A4RBzq.js} +3 -3
  2. package/dist/cjs/{index-Ctja7z-R.js.map → index-D8A4RBzq.js.map} +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/open-chat-studio-widget.cjs.entry.js +15 -7
  5. package/dist/cjs/open-chat-studio-widget.cjs.entry.js.map +1 -1
  6. package/dist/cjs/open-chat-studio-widget.cjs.js +1 -1
  7. package/dist/cjs/open-chat-studio-widget.entry.cjs.js.map +1 -1
  8. package/dist/collection/services/chat-session-service.js +14 -6
  9. package/dist/collection/services/chat-session-service.js.map +1 -1
  10. package/dist/components/open-chat-studio-widget.js +14 -6
  11. package/dist/components/open-chat-studio-widget.js.map +1 -1
  12. package/dist/esm/{index-BbCwiO7g.js → index-C53whb-B.js} +3 -3
  13. package/dist/esm/{index-BbCwiO7g.js.map → index-C53whb-B.js.map} +1 -1
  14. package/dist/esm/loader.js +2 -2
  15. package/dist/esm/open-chat-studio-widget.entry.js +15 -7
  16. package/dist/esm/open-chat-studio-widget.entry.js.map +1 -1
  17. package/dist/esm/open-chat-studio-widget.js +2 -2
  18. package/dist/open-chat-studio-widget/open-chat-studio-widget.entry.esm.js.map +1 -1
  19. package/dist/open-chat-studio-widget/open-chat-studio-widget.esm.js +1 -1
  20. package/dist/open-chat-studio-widget/{p-BbCwiO7g.js → p-C53whb-B.js} +2 -2
  21. package/dist/open-chat-studio-widget/{p-BbCwiO7g.js.map → p-C53whb-B.js.map} +1 -1
  22. package/dist/open-chat-studio-widget/p-b9556259.entry.js +4 -0
  23. package/dist/open-chat-studio-widget/p-b9556259.entry.js.map +1 -0
  24. package/dist/types/services/chat-session-service.d.ts +1 -0
  25. package/package.json +1 -1
  26. package/dist/open-chat-studio-widget/p-96920183.entry.js +0 -4
  27. package/dist/open-chat-studio-widget/p-96920183.entry.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { b as bootstrapLazy } from './index-BbCwiO7g.js';
2
- export { s as setNonce } from './index-BbCwiO7g.js';
1
+ import { b as bootstrapLazy } from './index-C53whb-B.js';
2
+ export { s as setNonce } from './index-C53whb-B.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  const defineCustomElements = async (win, options) => {
@@ -1,4 +1,4 @@
1
- import { h, r as registerInstance, E as Env, H as Host, g as getElement } from './index-BbCwiO7g.js';
1
+ import { h, r as registerInstance, E as Env, H as Host, g as getElement } from './index-C53whb-B.js';
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
4
  const OcsWidgetAvatar = () => {
@@ -4933,7 +4933,9 @@ class ChatSessionService {
4933
4933
  return response.json();
4934
4934
  }
4935
4935
  async pollTaskOnce(sessionId, taskId) {
4936
- const response = await fetch(`${this.apiBaseUrl}/api/chat/${sessionId}/${taskId}/poll/`);
4936
+ const response = await fetch(`${this.apiBaseUrl}/api/chat/${sessionId}/${taskId}/poll/`, {
4937
+ headers: this.getCommonHeaders(),
4938
+ });
4937
4939
  if (!response.ok) {
4938
4940
  throw new Error(`Failed to poll task: ${response.statusText}`);
4939
4941
  }
@@ -4991,7 +4993,9 @@ class ChatSessionService {
4991
4993
  if (since) {
4992
4994
  url.searchParams.set('since', since);
4993
4995
  }
4994
- const response = await fetch(url.toString());
4996
+ const response = await fetch(url.toString(), {
4997
+ headers: this.getCommonHeaders(),
4998
+ });
4995
4999
  if (!response.ok) {
4996
5000
  throw new Error(`Failed to poll messages: ${response.statusText}`);
4997
5001
  }
@@ -5028,14 +5032,18 @@ class ChatSessionService {
5028
5032
  }
5029
5033
  }
5030
5034
  getJsonHeaders() {
5031
- const headers = {
5032
- 'Content-Type': 'application/json',
5033
- 'x-ocs-widget-version': this.widgetVersion,
5034
- };
5035
+ const headers = this.getCommonHeaders();
5036
+ headers['Content-Type'] = 'application/json';
5035
5037
  const csrfToken = this.csrfTokenProvider(this.apiBaseUrl);
5036
5038
  if (csrfToken) {
5037
5039
  headers['X-CSRFToken'] = csrfToken;
5038
5040
  }
5041
+ return headers;
5042
+ }
5043
+ getCommonHeaders() {
5044
+ const headers = {
5045
+ 'x-ocs-widget-version': this.widgetVersion,
5046
+ };
5039
5047
  if (this.embedKey) {
5040
5048
  headers['X-Embed-Key'] = this.embedKey;
5041
5049
  }