@retrivora-ai/rag-engine 2.2.6 → 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.
@@ -51,6 +51,8 @@ interface UseRagChatOptions {
51
51
  onError?: (error: string) => void;
52
52
  /** Optional custom headers to send with the chat request */
53
53
  headers?: Record<string, string>;
54
+ /** Optional Retrivora license key override */
55
+ licenseKey?: string;
54
56
  /** Session ID for history and feedback tracking (default: 'default') */
55
57
  sessionId?: string;
56
58
  }
@@ -51,6 +51,8 @@ interface UseRagChatOptions {
51
51
  onError?: (error: string) => void;
52
52
  /** Optional custom headers to send with the chat request */
53
53
  headers?: Record<string, string>;
54
+ /** Optional Retrivora license key override */
55
+ licenseKey?: string;
54
56
  /** Session ID for history and feedback tracking (default: 'default') */
55
57
  sessionId?: string;
56
58
  }
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-BWa68XX5.js';
2
+ import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-teTNQ1lh.mjs';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -53,11 +53,12 @@ interface ChatWindowProps {
53
53
  onAddToCart?: (product: Product) => void;
54
54
  /** Optional custom API URL to send chat messages to */
55
55
  apiUrl?: string;
56
- /**
57
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
56
+ /** Base URL for Retrivora SDK history/feedback/sessions endpoints.
58
57
  * Defaults to '/api/retrivora'. Set this to match your catch-all route location.
59
58
  */
60
59
  retrivoraApiBase?: string;
60
+ /** Optional Retrivora license key override */
61
+ licenseKey?: string;
61
62
  /** Optional custom headers to send with the chat request */
62
63
  headers?: Record<string, string>;
63
64
  }
@@ -73,6 +74,8 @@ interface ChatWidgetProps {
73
74
  * Defaults to '/api/retrivora'.
74
75
  */
75
76
  retrivoraApiBase?: string;
77
+ /** Optional Retrivora license key override */
78
+ licenseKey?: string;
76
79
  /** Optional custom headers to send with the chat request */
77
80
  headers?: Record<string, string>;
78
81
  }
@@ -509,7 +512,7 @@ declare class Retrivora {
509
512
  /**
510
513
  * Named SDK exceptions make failures machine-readable for host applications.
511
514
  */
512
- type RetrivoraErrorCode = 'PROVIDER_NOT_FOUND' | 'EMBEDDING_FAILED' | 'RETRIEVAL_FAILED' | 'RATE_LIMITED' | 'CONFIGURATION_ERROR' | 'AUTHENTICATION_ERROR';
515
+ type RetrivoraErrorCode = 'PROVIDER_NOT_FOUND' | 'EMBEDDING_FAILED' | 'RETRIEVAL_FAILED' | 'RATE_LIMITED' | 'CONFIGURATION_ERROR' | 'AUTHENTICATION_ERROR' | 'SDK_VERSION_UNSUPPORTED' | 'LICENSE_VALIDATION_ERROR';
513
516
  declare class RetrivoraError extends Error {
514
517
  readonly code: RetrivoraErrorCode;
515
518
  readonly details?: unknown;
@@ -533,9 +536,49 @@ declare class ConfigurationException extends RetrivoraError {
533
536
  declare class AuthenticationException extends RetrivoraError {
534
537
  constructor(message?: string, details?: unknown);
535
538
  }
539
+ declare class SDKVersionUnsupportedError extends RetrivoraError {
540
+ constructor(message?: string, details?: unknown);
541
+ }
542
+ declare class LicenseValidationError extends RetrivoraError {
543
+ constructor(message?: string, details?: unknown);
544
+ }
536
545
  /**
537
546
  * Wraps any unknown error into an appropriate RetrivoraError subclass.
538
547
  */
539
548
  declare function wrapError(err: unknown, defaultCode: RetrivoraErrorCode, defaultMessage?: string): RetrivoraError;
540
549
 
541
- export { AuthenticationException as A, type ChatViewportSize as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, DocumentChunker as F, MixedRendererStrategy as G, Pipeline as H, type IRenderRule as I, type PipelineStep as J, type ProviderPill as K, type RenderSectionDecision as L, type MessageBubbleProps as M, type Snippet as N, TextRendererStrategy as O, type ProductCardProps as P, wrapError as Q, RateLimitException as R, type SourceCardProps as S, TableRendererStrategy as T, VisualizationDecisionEngine as V, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, ProviderNotFoundException as m, type RenderDecision as n, type RenderType as o, RendererRegistry as p, RetrievalException as q, Retrivora as r, RetrivoraError as s, type RetrivoraErrorCode as t, RuleEngine as u, SDK_VERSION as v, decideVisualization as w, type ArchitectureCardProps as x, CarouselRendererStrategy as y, ChartRendererStrategy as z };
550
+ interface LicenseValidationRequest {
551
+ licenseKey: string;
552
+ projectId?: string;
553
+ sdkVersion?: string;
554
+ sdk?: string;
555
+ platform?: string;
556
+ retrivoraApiBase?: string;
557
+ headers?: Record<string, string>;
558
+ }
559
+ interface LicenseValidationResponse {
560
+ valid: boolean;
561
+ licenseStatus: 'ACTIVE' | 'SUSPENDED' | 'TERMINATED' | 'EXPIRED' | 'REVOKED';
562
+ minimumSupportedVersion: string;
563
+ latestVersion: string;
564
+ forceUpgrade: boolean;
565
+ expiresAt: string | null;
566
+ message: string;
567
+ }
568
+ declare class LicenseValidator {
569
+ private static instance;
570
+ private cache;
571
+ private static readonly SUCCESS_CACHE_TTL_MS;
572
+ private constructor();
573
+ static getInstance(): LicenseValidator;
574
+ /**
575
+ * Invalidate local validation cache for a license key
576
+ */
577
+ purgeCache(licenseKey?: string): void;
578
+ /**
579
+ * Validate license status and SDK version against Retrivora License Service
580
+ */
581
+ validate(request: LicenseValidationRequest): Promise<LicenseValidationResponse>;
582
+ }
583
+
584
+ export { AuthenticationException as A, decideVisualization as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, type ArchitectureCardProps as F, CarouselRendererStrategy as G, ChartRendererStrategy as H, type IRenderRule as I, type ChatViewportSize as J, DocumentChunker as K, LicenseValidationError as L, type MessageBubbleProps as M, MixedRendererStrategy as N, Pipeline as O, type ProductCardProps as P, type PipelineStep as Q, RateLimitException as R, type SourceCardProps as S, type ProviderPill as T, type RenderSectionDecision as U, VisualizationDecisionEngine as V, type Snippet as W, TableRendererStrategy as X, TextRendererStrategy as Y, wrapError as Z, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, type LicenseValidationRequest as m, type LicenseValidationResponse as n, LicenseValidator as o, ProviderNotFoundException as p, type RenderDecision as q, type RenderType as r, RendererRegistry as s, RetrievalException as t, Retrivora as u, RetrivoraError as v, type RetrivoraErrorCode as w, RuleEngine as x, SDKVersionUnsupportedError as y, SDK_VERSION as z };
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEvent, ReactNode, ElementType } from 'react';
2
- import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-BWa68XX5.mjs';
2
+ import { y as Product, m as UIConfig, j as RagMessage, q as VectorMatch, J as UITransformationResponse, i as RagConfig, I as ILLMProvider, f as IngestDocument, C as ChatMessage, c as ChatResponse, z as RetrievalResult, n as UniversalRagConfig } from './ILLMProvider-teTNQ1lh.js';
3
3
 
4
4
  interface ArchitectureCardProps {
5
5
  icon: ReactNode;
@@ -53,11 +53,12 @@ interface ChatWindowProps {
53
53
  onAddToCart?: (product: Product) => void;
54
54
  /** Optional custom API URL to send chat messages to */
55
55
  apiUrl?: string;
56
- /**
57
- * Base URL for Retrivora SDK history/feedback/sessions endpoints.
56
+ /** Base URL for Retrivora SDK history/feedback/sessions endpoints.
58
57
  * Defaults to '/api/retrivora'. Set this to match your catch-all route location.
59
58
  */
60
59
  retrivoraApiBase?: string;
60
+ /** Optional Retrivora license key override */
61
+ licenseKey?: string;
61
62
  /** Optional custom headers to send with the chat request */
62
63
  headers?: Record<string, string>;
63
64
  }
@@ -73,6 +74,8 @@ interface ChatWidgetProps {
73
74
  * Defaults to '/api/retrivora'.
74
75
  */
75
76
  retrivoraApiBase?: string;
77
+ /** Optional Retrivora license key override */
78
+ licenseKey?: string;
76
79
  /** Optional custom headers to send with the chat request */
77
80
  headers?: Record<string, string>;
78
81
  }
@@ -509,7 +512,7 @@ declare class Retrivora {
509
512
  /**
510
513
  * Named SDK exceptions make failures machine-readable for host applications.
511
514
  */
512
- type RetrivoraErrorCode = 'PROVIDER_NOT_FOUND' | 'EMBEDDING_FAILED' | 'RETRIEVAL_FAILED' | 'RATE_LIMITED' | 'CONFIGURATION_ERROR' | 'AUTHENTICATION_ERROR';
515
+ type RetrivoraErrorCode = 'PROVIDER_NOT_FOUND' | 'EMBEDDING_FAILED' | 'RETRIEVAL_FAILED' | 'RATE_LIMITED' | 'CONFIGURATION_ERROR' | 'AUTHENTICATION_ERROR' | 'SDK_VERSION_UNSUPPORTED' | 'LICENSE_VALIDATION_ERROR';
513
516
  declare class RetrivoraError extends Error {
514
517
  readonly code: RetrivoraErrorCode;
515
518
  readonly details?: unknown;
@@ -533,9 +536,49 @@ declare class ConfigurationException extends RetrivoraError {
533
536
  declare class AuthenticationException extends RetrivoraError {
534
537
  constructor(message?: string, details?: unknown);
535
538
  }
539
+ declare class SDKVersionUnsupportedError extends RetrivoraError {
540
+ constructor(message?: string, details?: unknown);
541
+ }
542
+ declare class LicenseValidationError extends RetrivoraError {
543
+ constructor(message?: string, details?: unknown);
544
+ }
536
545
  /**
537
546
  * Wraps any unknown error into an appropriate RetrivoraError subclass.
538
547
  */
539
548
  declare function wrapError(err: unknown, defaultCode: RetrivoraErrorCode, defaultMessage?: string): RetrivoraError;
540
549
 
541
- export { AuthenticationException as A, type ChatViewportSize as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, DocumentChunker as F, MixedRendererStrategy as G, Pipeline as H, type IRenderRule as I, type PipelineStep as J, type ProviderPill as K, type RenderSectionDecision as L, type MessageBubbleProps as M, type Snippet as N, TextRendererStrategy as O, type ProductCardProps as P, wrapError as Q, RateLimitException as R, type SourceCardProps as S, TableRendererStrategy as T, VisualizationDecisionEngine as V, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, ProviderNotFoundException as m, type RenderDecision as n, type RenderType as o, RendererRegistry as p, RetrievalException as q, Retrivora as r, RetrivoraError as s, type RetrivoraErrorCode as t, RuleEngine as u, SDK_VERSION as v, decideVisualization as w, type ArchitectureCardProps as x, CarouselRendererStrategy as y, ChartRendererStrategy as z };
550
+ interface LicenseValidationRequest {
551
+ licenseKey: string;
552
+ projectId?: string;
553
+ sdkVersion?: string;
554
+ sdk?: string;
555
+ platform?: string;
556
+ retrivoraApiBase?: string;
557
+ headers?: Record<string, string>;
558
+ }
559
+ interface LicenseValidationResponse {
560
+ valid: boolean;
561
+ licenseStatus: 'ACTIVE' | 'SUSPENDED' | 'TERMINATED' | 'EXPIRED' | 'REVOKED';
562
+ minimumSupportedVersion: string;
563
+ latestVersion: string;
564
+ forceUpgrade: boolean;
565
+ expiresAt: string | null;
566
+ message: string;
567
+ }
568
+ declare class LicenseValidator {
569
+ private static instance;
570
+ private cache;
571
+ private static readonly SUCCESS_CACHE_TTL_MS;
572
+ private constructor();
573
+ static getInstance(): LicenseValidator;
574
+ /**
575
+ * Invalidate local validation cache for a license key
576
+ */
577
+ purgeCache(licenseKey?: string): void;
578
+ /**
579
+ * Validate license status and SDK version against Retrivora License Service
580
+ */
581
+ validate(request: LicenseValidationRequest): Promise<LicenseValidationResponse>;
582
+ }
583
+
584
+ export { AuthenticationException as A, decideVisualization as B, type ChatWidgetProps as C, type DocumentUploadProps as D, EmbeddingFailedException as E, type ArchitectureCardProps as F, CarouselRendererStrategy as G, ChartRendererStrategy as H, type IRenderRule as I, type ChatViewportSize as J, DocumentChunker as K, LicenseValidationError as L, type MessageBubbleProps as M, MixedRendererStrategy as N, Pipeline as O, type ProductCardProps as P, type PipelineStep as Q, RateLimitException as R, type SourceCardProps as S, type ProviderPill as T, type RenderSectionDecision as U, VisualizationDecisionEngine as V, type Snippet as W, TableRendererStrategy as X, TextRendererStrategy as Y, wrapError as Z, type ChatWindowProps as a, type ConfigProviderProps as b, type ClientConfig as c, type ProductCarouselProps as d, type ChartType as e, type Chunk as f, type ChunkOptions as g, ConfigurationException as h, type DecisionContext as i, type IRendererStrategy as j, type IntentCategory as k, IntentClassifier as l, type LicenseValidationRequest as m, type LicenseValidationResponse as n, LicenseValidator as o, ProviderNotFoundException as p, type RenderDecision as q, type RenderType as r, RendererRegistry as s, RetrievalException as t, Retrivora as u, RetrivoraError as v, type RetrivoraErrorCode as w, RuleEngine as x, SDKVersionUnsupportedError as y, SDK_VERSION as z };
@@ -1,3 +1,3 @@
1
1
  import 'next/server';
2
- export { o as HandlerOptions, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, p as createSuggestionsHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, q as sseObservabilityFrame, n as sseTextFrame, r as sseUIFrame } from '../index-DvbtNz7m.mjs';
3
- import '../ILLMProvider-BWa68XX5.mjs';
2
+ export { o as HandlerOptions, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, p as createLicenseHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, q as createSuggestionsHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, r as sseObservabilityFrame, n as sseTextFrame, t as sseUIFrame } from '../index-Dmq5lH0j.mjs';
3
+ import '../ILLMProvider-teTNQ1lh.mjs';
@@ -1,3 +1,3 @@
1
1
  import 'next/server';
2
- export { o as HandlerOptions, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, p as createSuggestionsHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, q as sseObservabilityFrame, n as sseTextFrame, r as sseUIFrame } from '../index-B5TTZWkx.js';
3
- import '../ILLMProvider-BWa68XX5.js';
2
+ export { o as HandlerOptions, c as createChatHandler, d as createFeedbackHandler, e as createHealthHandler, f as createHistoryHandler, g as createIngestHandler, p as createLicenseHandler, h as createRagHandler, i as createSessionsHandler, j as createStreamHandler, q as createSuggestionsHandler, k as createUploadHandler, s as sseErrorFrame, l as sseFrame, m as sseMetaFrame, r as sseObservabilityFrame, n as sseTextFrame, t as sseUIFrame } from '../index-BPJ3KDYI.js';
3
+ import '../ILLMProvider-teTNQ1lh.js';
@@ -2209,6 +2209,7 @@ __export(handlers_exports, {
2209
2209
  createHealthHandler: () => createHealthHandler,
2210
2210
  createHistoryHandler: () => createHistoryHandler,
2211
2211
  createIngestHandler: () => createIngestHandler,
2212
+ createLicenseHandler: () => createLicenseHandler,
2212
2213
  createRagHandler: () => createRagHandler,
2213
2214
  createSessionsHandler: () => createSessionsHandler,
2214
2215
  createStreamHandler: () => createStreamHandler,
@@ -2281,8 +2282,10 @@ function wrapError(err, defaultCode, defaultMessage) {
2281
2282
  if (status === 429 || /rate[- ]?limit/i.test(message) || code === "RATE_LIMIT_EXCEEDED") {
2282
2283
  return new RateLimitException(message, err);
2283
2284
  }
2284
- if (status === 401 || status === 403 || /unauthorized|auth|api[- ]?key/i.test(message) || code === "INVALID_API_KEY") {
2285
- return new AuthenticationException(message, err);
2285
+ if (status === 401 || status === 403 || /unauthorized|auth|license|revoked|terminated|api[- ]?key/i.test(message) || code === "INVALID_API_KEY" || code === "LICENSE_DELETED" || code === "LICENSE_INACTIVE") {
2286
+ const isLicenseError = /403|license|revoked|terminated/i.test(message) || status === 403;
2287
+ const cleanMsg = isLicenseError ? "Your Retrivora license key has been terminated, suspended, or revoked. Access denied." : message;
2288
+ return new AuthenticationException(cleanMsg, err);
2286
2289
  }
2287
2290
  switch (defaultCode) {
2288
2291
  case "PROVIDER_NOT_FOUND":
@@ -4707,7 +4710,7 @@ var ConfigValidator = class {
4707
4710
  // package.json
4708
4711
  var package_default = {
4709
4712
  name: "@retrivora-ai/rag-engine",
4710
- version: "2.2.6",
4713
+ version: "2.2.8",
4711
4714
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
4712
4715
  author: "Abhinav Alkuchi",
4713
4716
  license: "UNLICENSED",
@@ -10510,7 +10513,10 @@ function createStreamHandler(configOrPlugin, options) {
10510
10513
  }
10511
10514
  } catch (streamError) {
10512
10515
  if (isActive) {
10513
- const errorMessage = streamError instanceof Error ? streamError.message : String(streamError);
10516
+ let errorMessage = streamError instanceof Error ? streamError.message : String(streamError);
10517
+ if (errorMessage.includes("403") || errorMessage.toLowerCase().includes("license") || errorMessage.toLowerCase().includes("revoked") || errorMessage.toLowerCase().includes("terminated")) {
10518
+ errorMessage = "Your Retrivora license key has been terminated, suspended, or revoked. Access denied.";
10519
+ }
10514
10520
  console.error("[createStreamHandler] Stream error:", streamError);
10515
10521
  reportTelemetry(req, plugin, "QUERY_GENERATION", "error", errorMessage);
10516
10522
  try {
@@ -10580,6 +10586,46 @@ function createHealthHandler(configOrPlugin, options) {
10580
10586
  }
10581
10587
  };
10582
10588
  }
10589
+ function createLicenseHandler(configOrPlugin, options) {
10590
+ const plugin = getOrCreatePlugin(configOrPlugin);
10591
+ const onAuthorize = options == null ? void 0 : options.onAuthorize;
10592
+ return async function POST(req) {
10593
+ var _a2;
10594
+ if (req) {
10595
+ const authResult = await checkAuth(req, onAuthorize);
10596
+ if (authResult) return authResult;
10597
+ }
10598
+ try {
10599
+ const body = await req.json().catch(() => ({}));
10600
+ const config = plugin.getConfig();
10601
+ const licenseKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a2 = req.headers.get("authorization")) == null ? void 0 : _a2.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || "";
10602
+ const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "my-rag-app";
10603
+ const payload = LicenseVerifier.verify(licenseKey, projectId);
10604
+ return import_server.NextResponse.json({
10605
+ valid: true,
10606
+ licenseStatus: "ACTIVE",
10607
+ minimumSupportedVersion: "2.1.0",
10608
+ latestVersion: SDK_VERSION,
10609
+ forceUpgrade: false,
10610
+ expiresAt: payload.expiresAt ? new Date(payload.expiresAt * 1e3).toISOString() : null,
10611
+ message: "License key is active and valid."
10612
+ });
10613
+ } catch (err) {
10614
+ return import_server.NextResponse.json(
10615
+ {
10616
+ valid: false,
10617
+ licenseStatus: "REVOKED",
10618
+ minimumSupportedVersion: "2.1.0",
10619
+ latestVersion: SDK_VERSION,
10620
+ forceUpgrade: false,
10621
+ expiresAt: null,
10622
+ message: (err == null ? void 0 : err.message) || "License validation failed."
10623
+ },
10624
+ { status: 400 }
10625
+ );
10626
+ }
10627
+ };
10628
+ }
10583
10629
  function createUploadHandler(configOrPlugin, options) {
10584
10630
  const plugin = getOrCreatePlugin(configOrPlugin);
10585
10631
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
@@ -10831,6 +10877,7 @@ function createRagHandler(configOrPlugin, options) {
10831
10877
  const historyHandler = createHistoryHandler(plugin, { onAuthorize });
10832
10878
  const feedbackHandler = createFeedbackHandler(plugin, { onAuthorize });
10833
10879
  const sessionsHandler = createSessionsHandler(plugin, { onAuthorize });
10880
+ const licenseHandler = createLicenseHandler(plugin, { onAuthorize });
10834
10881
  async function routePostRequest(req, segment) {
10835
10882
  switch (segment) {
10836
10883
  case "chat":
@@ -10848,6 +10895,9 @@ function createRagHandler(configOrPlugin, options) {
10848
10895
  return historyHandler(req);
10849
10896
  case "feedback":
10850
10897
  return feedbackHandler(req);
10898
+ case "license/validate":
10899
+ case "v1/license/validate":
10900
+ return licenseHandler(req);
10851
10901
  default:
10852
10902
  return import_server.NextResponse.json({ error: `Not Found: POST segment "${segment}" not supported.` }, { status: 404 });
10853
10903
  }
@@ -10877,6 +10927,7 @@ function createRagHandler(configOrPlugin, options) {
10877
10927
  try {
10878
10928
  const url = new URL(req.url);
10879
10929
  const pathname = url.pathname;
10930
+ if (pathname.includes("/license/validate")) return "v1/license/validate";
10880
10931
  if (pathname.endsWith("/upload")) return "upload";
10881
10932
  if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
10882
10933
  if (pathname.endsWith("/health")) return "health";
@@ -10918,6 +10969,7 @@ function createRagHandler(configOrPlugin, options) {
10918
10969
  createHealthHandler,
10919
10970
  createHistoryHandler,
10920
10971
  createIngestHandler,
10972
+ createLicenseHandler,
10921
10973
  createRagHandler,
10922
10974
  createSessionsHandler,
10923
10975
  createStreamHandler,
@@ -2246,8 +2246,10 @@ function wrapError(err, defaultCode, defaultMessage) {
2246
2246
  if (status === 429 || /rate[- ]?limit/i.test(message) || code === "RATE_LIMIT_EXCEEDED") {
2247
2247
  return new RateLimitException(message, err);
2248
2248
  }
2249
- if (status === 401 || status === 403 || /unauthorized|auth|api[- ]?key/i.test(message) || code === "INVALID_API_KEY") {
2250
- return new AuthenticationException(message, err);
2249
+ if (status === 401 || status === 403 || /unauthorized|auth|license|revoked|terminated|api[- ]?key/i.test(message) || code === "INVALID_API_KEY" || code === "LICENSE_DELETED" || code === "LICENSE_INACTIVE") {
2250
+ const isLicenseError = /403|license|revoked|terminated/i.test(message) || status === 403;
2251
+ const cleanMsg = isLicenseError ? "Your Retrivora license key has been terminated, suspended, or revoked. Access denied." : message;
2252
+ return new AuthenticationException(cleanMsg, err);
2251
2253
  }
2252
2254
  switch (defaultCode) {
2253
2255
  case "PROVIDER_NOT_FOUND":
@@ -4672,7 +4674,7 @@ var ConfigValidator = class {
4672
4674
  // package.json
4673
4675
  var package_default = {
4674
4676
  name: "@retrivora-ai/rag-engine",
4675
- version: "2.2.6",
4677
+ version: "2.2.8",
4676
4678
  description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
4677
4679
  author: "Abhinav Alkuchi",
4678
4680
  license: "UNLICENSED",
@@ -10475,7 +10477,10 @@ function createStreamHandler(configOrPlugin, options) {
10475
10477
  }
10476
10478
  } catch (streamError) {
10477
10479
  if (isActive) {
10478
- const errorMessage = streamError instanceof Error ? streamError.message : String(streamError);
10480
+ let errorMessage = streamError instanceof Error ? streamError.message : String(streamError);
10481
+ if (errorMessage.includes("403") || errorMessage.toLowerCase().includes("license") || errorMessage.toLowerCase().includes("revoked") || errorMessage.toLowerCase().includes("terminated")) {
10482
+ errorMessage = "Your Retrivora license key has been terminated, suspended, or revoked. Access denied.";
10483
+ }
10479
10484
  console.error("[createStreamHandler] Stream error:", streamError);
10480
10485
  reportTelemetry(req, plugin, "QUERY_GENERATION", "error", errorMessage);
10481
10486
  try {
@@ -10545,6 +10550,46 @@ function createHealthHandler(configOrPlugin, options) {
10545
10550
  }
10546
10551
  };
10547
10552
  }
10553
+ function createLicenseHandler(configOrPlugin, options) {
10554
+ const plugin = getOrCreatePlugin(configOrPlugin);
10555
+ const onAuthorize = options == null ? void 0 : options.onAuthorize;
10556
+ return async function POST(req) {
10557
+ var _a2;
10558
+ if (req) {
10559
+ const authResult = await checkAuth(req, onAuthorize);
10560
+ if (authResult) return authResult;
10561
+ }
10562
+ try {
10563
+ const body = await req.json().catch(() => ({}));
10564
+ const config = plugin.getConfig();
10565
+ const licenseKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a2 = req.headers.get("authorization")) == null ? void 0 : _a2.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.RETRIVORA_LICENSE_KEY || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || "";
10566
+ const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "my-rag-app";
10567
+ const payload = LicenseVerifier.verify(licenseKey, projectId);
10568
+ return NextResponse.json({
10569
+ valid: true,
10570
+ licenseStatus: "ACTIVE",
10571
+ minimumSupportedVersion: "2.1.0",
10572
+ latestVersion: SDK_VERSION,
10573
+ forceUpgrade: false,
10574
+ expiresAt: payload.expiresAt ? new Date(payload.expiresAt * 1e3).toISOString() : null,
10575
+ message: "License key is active and valid."
10576
+ });
10577
+ } catch (err) {
10578
+ return NextResponse.json(
10579
+ {
10580
+ valid: false,
10581
+ licenseStatus: "REVOKED",
10582
+ minimumSupportedVersion: "2.1.0",
10583
+ latestVersion: SDK_VERSION,
10584
+ forceUpgrade: false,
10585
+ expiresAt: null,
10586
+ message: (err == null ? void 0 : err.message) || "License validation failed."
10587
+ },
10588
+ { status: 400 }
10589
+ );
10590
+ }
10591
+ };
10592
+ }
10548
10593
  function createUploadHandler(configOrPlugin, options) {
10549
10594
  const plugin = getOrCreatePlugin(configOrPlugin);
10550
10595
  const onAuthorize = options == null ? void 0 : options.onAuthorize;
@@ -10796,6 +10841,7 @@ function createRagHandler(configOrPlugin, options) {
10796
10841
  const historyHandler = createHistoryHandler(plugin, { onAuthorize });
10797
10842
  const feedbackHandler = createFeedbackHandler(plugin, { onAuthorize });
10798
10843
  const sessionsHandler = createSessionsHandler(plugin, { onAuthorize });
10844
+ const licenseHandler = createLicenseHandler(plugin, { onAuthorize });
10799
10845
  async function routePostRequest(req, segment) {
10800
10846
  switch (segment) {
10801
10847
  case "chat":
@@ -10813,6 +10859,9 @@ function createRagHandler(configOrPlugin, options) {
10813
10859
  return historyHandler(req);
10814
10860
  case "feedback":
10815
10861
  return feedbackHandler(req);
10862
+ case "license/validate":
10863
+ case "v1/license/validate":
10864
+ return licenseHandler(req);
10816
10865
  default:
10817
10866
  return NextResponse.json({ error: `Not Found: POST segment "${segment}" not supported.` }, { status: 404 });
10818
10867
  }
@@ -10842,6 +10891,7 @@ function createRagHandler(configOrPlugin, options) {
10842
10891
  try {
10843
10892
  const url = new URL(req.url);
10844
10893
  const pathname = url.pathname;
10894
+ if (pathname.includes("/license/validate")) return "v1/license/validate";
10845
10895
  if (pathname.endsWith("/upload")) return "upload";
10846
10896
  if (pathname.endsWith("/chat") || pathname.endsWith("/chat-sync")) return "chat";
10847
10897
  if (pathname.endsWith("/health")) return "health";
@@ -10882,6 +10932,7 @@ export {
10882
10932
  createHealthHandler,
10883
10933
  createHistoryHandler,
10884
10934
  createIngestHandler,
10935
+ createLicenseHandler,
10885
10936
  createRagHandler,
10886
10937
  createSessionsHandler,
10887
10938
  createStreamHandler,
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-BWa68XX5.mjs';
2
+ import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-teTNQ1lh.js';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;
@@ -158,6 +158,10 @@ declare function createIngestHandler(configOrPlugin?: Partial<RagConfig> | Vecto
158
158
  * createHealthHandler — factory for the health-check endpoint.
159
159
  */
160
160
  declare function createHealthHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req?: NextRequest) => Promise<any>;
161
+ /**
162
+ * createLicenseHandler — factory for the license validation endpoint (/v1/license/validate).
163
+ */
164
+ declare function createLicenseHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
161
165
  /**
162
166
  * createUploadHandler — factory for the file upload ingestion endpoint.
163
167
  */
@@ -188,4 +192,4 @@ declare function createRagHandler(configOrPlugin?: Partial<RagConfig> | VectorPl
188
192
  POST: (req: any, context?: any) => Promise<any>;
189
193
  };
190
194
 
191
- export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createFeedbackHandler as d, createHealthHandler as e, createHistoryHandler as f, createIngestHandler as g, createRagHandler as h, createSessionsHandler as i, createStreamHandler as j, createUploadHandler as k, sseFrame as l, sseMetaFrame as m, sseTextFrame as n, type HandlerOptions as o, createSuggestionsHandler as p, sseObservabilityFrame as q, sseUIFrame as r, sseErrorFrame as s };
195
+ export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createFeedbackHandler as d, createHealthHandler as e, createHistoryHandler as f, createIngestHandler as g, createRagHandler as h, createSessionsHandler as i, createStreamHandler as j, createUploadHandler as k, sseFrame as l, sseMetaFrame as m, sseTextFrame as n, type HandlerOptions as o, createLicenseHandler as p, createSuggestionsHandler as q, sseObservabilityFrame as r, sseErrorFrame as s, sseUIFrame as t };
@@ -1,5 +1,5 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-BWa68XX5.js';
2
+ import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-teTNQ1lh.mjs';
3
3
 
4
4
  interface ValidationError {
5
5
  field: string;
@@ -158,6 +158,10 @@ declare function createIngestHandler(configOrPlugin?: Partial<RagConfig> | Vecto
158
158
  * createHealthHandler — factory for the health-check endpoint.
159
159
  */
160
160
  declare function createHealthHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req?: NextRequest) => Promise<any>;
161
+ /**
162
+ * createLicenseHandler — factory for the license validation endpoint (/v1/license/validate).
163
+ */
164
+ declare function createLicenseHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
161
165
  /**
162
166
  * createUploadHandler — factory for the file upload ingestion endpoint.
163
167
  */
@@ -188,4 +192,4 @@ declare function createRagHandler(configOrPlugin?: Partial<RagConfig> | VectorPl
188
192
  POST: (req: any, context?: any) => Promise<any>;
189
193
  };
190
194
 
191
- export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createFeedbackHandler as d, createHealthHandler as e, createHistoryHandler as f, createIngestHandler as g, createRagHandler as h, createSessionsHandler as i, createStreamHandler as j, createUploadHandler as k, sseFrame as l, sseMetaFrame as m, sseTextFrame as n, type HandlerOptions as o, createSuggestionsHandler as p, sseObservabilityFrame as q, sseUIFrame as r, sseErrorFrame as s };
195
+ export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createFeedbackHandler as d, createHealthHandler as e, createHistoryHandler as f, createIngestHandler as g, createRagHandler as h, createSessionsHandler as i, createStreamHandler as j, createUploadHandler as k, sseFrame as l, sseMetaFrame as m, sseTextFrame as n, type HandlerOptions as o, createLicenseHandler as p, createSuggestionsHandler as q, sseObservabilityFrame as r, sseErrorFrame as s, sseUIFrame as t };
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps } from './index-BbJGyNmW.mjs';
3
- export { A as AuthenticationException, e as ChartType, f as Chunk, g as ChunkOptions, h as ConfigurationException, i as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, j as IRendererStrategy, k as IntentCategory, l as IntentClassifier, m as ProviderNotFoundException, R as RateLimitException, n as RenderDecision, o as RenderType, p as RendererRegistry, q as RetrievalException, r as Retrivora, s as RetrivoraError, t as RetrivoraErrorCode, u as RuleEngine, v as SDK_VERSION, V as VisualizationDecisionEngine, w as decideVisualization } from './index-BbJGyNmW.mjs';
4
- import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn } from './ILLMProvider-BWa68XX5.mjs';
5
- export { C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, R as RAGConfig, i as RagConfig, j as RagMessage, k as RetrievalConfig, l as RetrievedChunk, T as TokenUsage, m as UIConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorDBConfig, p as VectorDBProvider, q as VectorMatch, W as WorkflowConfig } from './ILLMProvider-BWa68XX5.mjs';
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps } from './LicenseValidator-CENvo9o2.mjs';
3
+ export { A as AuthenticationException, e as ChartType, f as Chunk, g as ChunkOptions, h as ConfigurationException, i as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, j as IRendererStrategy, k as IntentCategory, l as IntentClassifier, L as LicenseValidationError, m as LicenseValidationRequest, n as LicenseValidationResponse, o as LicenseValidator, p as ProviderNotFoundException, R as RateLimitException, q as RenderDecision, r as RenderType, s as RendererRegistry, t as RetrievalException, u as Retrivora, v as RetrivoraError, w as RetrivoraErrorCode, x as RuleEngine, y as SDKVersionUnsupportedError, z as SDK_VERSION, V as VisualizationDecisionEngine, B as decideVisualization } from './LicenseValidator-CENvo9o2.mjs';
4
+ import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn } from './ILLMProvider-teTNQ1lh.mjs';
5
+ export { C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, R as RAGConfig, i as RagConfig, j as RagMessage, k as RetrievalConfig, l as RetrievedChunk, T as TokenUsage, m as UIConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorDBConfig, p as VectorDBProvider, q as VectorMatch, W as WorkflowConfig } from './ILLMProvider-teTNQ1lh.mjs';
6
6
  import 'react';
7
7
 
8
- declare function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
8
+ declare function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, licenseKey: licenseKeyProp, headers }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
9
9
 
10
- declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWindowProps): react_jsx_runtime.JSX.Element;
10
+ declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart, apiUrl, retrivoraApiBase, licenseKey: licenseKeyProp, headers }: ChatWindowProps): react_jsx_runtime.JSX.Element;
11
11
 
12
12
  declare function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComplete, className }: DocumentUploadProps): react_jsx_runtime.JSX.Element;
13
13
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps } from './index-BCbeeh74.js';
3
- export { A as AuthenticationException, e as ChartType, f as Chunk, g as ChunkOptions, h as ConfigurationException, i as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, j as IRendererStrategy, k as IntentCategory, l as IntentClassifier, m as ProviderNotFoundException, R as RateLimitException, n as RenderDecision, o as RenderType, p as RendererRegistry, q as RetrievalException, r as Retrivora, s as RetrivoraError, t as RetrivoraErrorCode, u as RuleEngine, v as SDK_VERSION, V as VisualizationDecisionEngine, w as decideVisualization } from './index-BCbeeh74.js';
4
- import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn } from './ILLMProvider-BWa68XX5.js';
5
- export { C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, R as RAGConfig, i as RagConfig, j as RagMessage, k as RetrievalConfig, l as RetrievedChunk, T as TokenUsage, m as UIConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorDBConfig, p as VectorDBProvider, q as VectorMatch, W as WorkflowConfig } from './ILLMProvider-BWa68XX5.js';
2
+ import { C as ChatWidgetProps, a as ChatWindowProps, D as DocumentUploadProps, M as MessageBubbleProps, S as SourceCardProps, b as ConfigProviderProps, c as ClientConfig, P as ProductCardProps, d as ProductCarouselProps } from './LicenseValidator-CsjJp2PP.js';
3
+ export { A as AuthenticationException, e as ChartType, f as Chunk, g as ChunkOptions, h as ConfigurationException, i as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, j as IRendererStrategy, k as IntentCategory, l as IntentClassifier, L as LicenseValidationError, m as LicenseValidationRequest, n as LicenseValidationResponse, o as LicenseValidator, p as ProviderNotFoundException, R as RateLimitException, q as RenderDecision, r as RenderType, s as RendererRegistry, t as RetrievalException, u as Retrivora, v as RetrivoraError, w as RetrivoraErrorCode, x as RuleEngine, y as SDKVersionUnsupportedError, z as SDK_VERSION, V as VisualizationDecisionEngine, B as decideVisualization } from './LicenseValidator-CsjJp2PP.js';
4
+ import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn } from './ILLMProvider-teTNQ1lh.js';
5
+ export { C as ChatMessage, b as ChatOptions, c as ChatResponse, E as EmbedOptions, d as EmbeddingConfig, e as EmbeddingProvider, I as ILLMProvider, f as IngestDocument, L as LLMConfig, g as LLMProvider, h as LatencyBreakdown, R as RAGConfig, i as RagConfig, j as RagMessage, k as RetrievalConfig, l as RetrievedChunk, T as TokenUsage, m as UIConfig, n as UniversalRagConfig, o as UpsertDocument, V as VectorDBConfig, p as VectorDBProvider, q as VectorMatch, W as WorkflowConfig } from './ILLMProvider-teTNQ1lh.js';
6
6
  import 'react';
7
7
 
8
- declare function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
8
+ declare function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, licenseKey: licenseKeyProp, headers }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
9
9
 
10
- declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart, apiUrl, retrivoraApiBase, headers }: ChatWindowProps): react_jsx_runtime.JSX.Element;
10
+ declare function ChatWindow({ className, style, onClose, showClose, onResizeStart, onResetResize, isResized, onMaximize, isMaximized, onAddToCart, apiUrl, retrivoraApiBase, licenseKey: licenseKeyProp, headers }: ChatWindowProps): react_jsx_runtime.JSX.Element;
11
11
 
12
12
  declare function DocumentUpload({ namespace, uploadUrl, retrivoraApiBase, onUploadComplete, className }: DocumentUploadProps): react_jsx_runtime.JSX.Element;
13
13