@retrivora-ai/rag-engine 2.2.7 → 2.2.8

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.
@@ -129,8 +129,27 @@ export function useRagChat(
129
129
  userMessageId: userMsgId,
130
130
  });
131
131
 
132
- const fetchHeaders = {
132
+ const getHeader = (headersObj: Record<string, string> | undefined, name: string) => {
133
+ if (!headersObj) return undefined;
134
+ const target = name.toLowerCase();
135
+ for (const [k, v] of Object.entries(headersObj)) {
136
+ if (k.toLowerCase() === target) return v;
137
+ }
138
+ return undefined;
139
+ };
140
+
141
+ const resolvedLicenseKey =
142
+ options.licenseKey ||
143
+ getHeader(options.headers, 'x-license-key') ||
144
+ getHeader(options.headers, 'authorization')?.replace(/^Bearer\s+/i, '') ||
145
+ (typeof process !== 'undefined'
146
+ ? (process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY)
147
+ : '') ||
148
+ '';
149
+
150
+ const fetchHeaders: Record<string, string> = {
133
151
  'Content-Type': 'application/json',
152
+ ...(resolvedLicenseKey ? { 'x-license-key': resolvedLicenseKey } : {}),
134
153
  ...(options.headers || {})
135
154
  };
136
155
 
package/src/types/chat.ts CHANGED
@@ -57,6 +57,8 @@ export interface UseRagChatOptions {
57
57
  onError?: (error: string) => void;
58
58
  /** Optional custom headers to send with the chat request */
59
59
  headers?: Record<string, string>;
60
+ /** Optional Retrivora license key override */
61
+ licenseKey?: string;
60
62
  /** Session ID for history and feedback tracking (default: 'default') */
61
63
  sessionId?: string;
62
64
  }
@@ -57,11 +57,12 @@ export interface ChatWindowProps {
57
57
  onAddToCart?: (product: Product) => void;
58
58
  /** Optional custom API URL to send chat messages to */
59
59
  apiUrl?: string;
60
- /**
61
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
60
+ /** Base URL for Retrivora SDK history/feedback/sessions endpoints.
62
61
  * Defaults to '/api/retrivora'. Set this to match your catch-all route location.
63
62
  */
64
63
  retrivoraApiBase?: string;
64
+ /** Optional Retrivora license key override */
65
+ licenseKey?: string;
65
66
  /** Optional custom headers to send with the chat request */
66
67
  headers?: Record<string, string>;
67
68
  }
@@ -78,6 +79,8 @@ export interface ChatWidgetProps {
78
79
  * Defaults to '/api/retrivora'.
79
80
  */
80
81
  retrivoraApiBase?: string;
82
+ /** Optional Retrivora license key override */
83
+ licenseKey?: string;
81
84
  /** Optional custom headers to send with the chat request */
82
85
  headers?: Record<string, string>;
83
86
  }