@retrivora-ai/rag-engine 2.3.6 → 2.3.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.
- package/dist/{BatchProcessor-Dfn23VAd.d.mts → BatchProcessor-BhLczWj5.d.mts} +100 -2
- package/dist/{BatchProcessor-ByBl-1MA.d.ts → BatchProcessor-C42_RVWO.d.ts} +100 -2
- package/dist/handlers/index.d.mts +1 -1
- package/dist/handlers/index.d.ts +1 -1
- package/dist/handlers/index.js +340 -172
- package/dist/handlers/index.mjs +342 -174
- package/dist/{index-ejOWsaqb.d.ts → index-BQd6Bax0.d.ts} +1 -1
- package/dist/{index-xxQOFx-u.d.mts → index-C7aHK7_g.d.mts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +114 -87
- package/dist/index.mjs +114 -87
- package/dist/server.d.mts +263 -37
- package/dist/server.d.ts +263 -37
- package/dist/server.js +957 -178
- package/dist/server.mjs +949 -180
- package/package.json +1 -1
- package/src/LicensedRetrivora.ts +273 -0
- package/src/components/ChatWidget.tsx +0 -1
- package/src/components/ConfigProvider.tsx +2 -1
- package/src/config/LicenseConfigResolver.ts +296 -0
- package/src/config/serverConfig.ts +75 -16
- package/src/core/ConfigFetcher.ts +36 -3
- package/src/core/DatabaseStorage.ts +13 -13
- package/src/core/LicenseValidator.ts +5 -3
- package/src/core/LicenseVerifier.ts +85 -120
- package/src/core/Retrivora.ts +1 -1
- package/src/core/VectorPlugin.ts +1 -1
- package/src/handlers/index.ts +25 -11
- package/src/index.ts +9 -0
- package/src/llm/providers/UniversalLLMAdapter.ts +67 -12
- package/src/providers/vectordb/PineconeProvider.ts +69 -2
- package/src/server.ts +23 -1
- package/src/telemetry/TelemetryService.ts +330 -0
|
@@ -263,7 +263,7 @@ declare function createHealthHandler(configOrPlugin?: Partial<RagConfig> | Vecto
|
|
|
263
263
|
*
|
|
264
264
|
* Client flow: `LicenseValidator.validate()` calls this URL, receives
|
|
265
265
|
* authoritative DB-backed status (ACTIVE / TERMINATED / SUSPENDED / EXPIRED /
|
|
266
|
-
|
|
266
|
+
// REVOKED), and falls back to pure-local `LicenseVerifier.verifyAsync()` if the
|
|
267
267
|
* server is unreachable or returns an error.
|
|
268
268
|
*
|
|
269
269
|
* This handler does NOT enforce license — it is the verifier itself. It does,
|
|
@@ -263,7 +263,7 @@ declare function createHealthHandler(configOrPlugin?: Partial<RagConfig> | Vecto
|
|
|
263
263
|
*
|
|
264
264
|
* Client flow: `LicenseValidator.validate()` calls this URL, receives
|
|
265
265
|
* authoritative DB-backed status (ACTIVE / TERMINATED / SUSPENDED / EXPIRED /
|
|
266
|
-
|
|
266
|
+
// REVOKED), and falls back to pure-local `LicenseVerifier.verifyAsync()` if the
|
|
267
267
|
* server is unreachable or returns an error.
|
|
268
268
|
*
|
|
269
269
|
* This handler does NOT enforce license — it is the verifier itself. It does,
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, R as RemoteConfig } from './BatchProcessor-
|
|
3
|
-
export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as
|
|
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, R as RemoteConfig } from './BatchProcessor-BhLczWj5.mjs';
|
|
3
|
+
export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-BhLczWj5.mjs';
|
|
4
4
|
import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn, P as ProjectChatSettings } from './ILLMProvider-B8TAVx3j.mjs';
|
|
5
5
|
export { A as AuthMode, 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, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, R as RAGConfig, n as RagConfig, o as RagMessage, p as RetrievalConfig, q as RetrievedChunk, T as ThemeMode, r as TokenUsage, s as UIConfig, t as UniversalRagConfig, u as UpsertDocument, V as VectorDBConfig, v as VectorDBProvider, w as VectorMatch, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-B8TAVx3j.mjs';
|
|
6
6
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, R as RemoteConfig } from './BatchProcessor-
|
|
3
|
-
export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as
|
|
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, R as RemoteConfig } from './BatchProcessor-C42_RVWO.js';
|
|
3
|
+
export { A as AuthenticationException, B as BatchOptions, e as BatchProcessor, f as BatchResult, g as ChartType, h as Chunk, i as ChunkOptions, j as ConfigFetcher, k as ConfigurationException, l as DecisionContext, E as EmbeddingFailedException, I as IRenderRule, m as IRendererStrategy, n as IntentCategory, L as LicenseTierConfig, o as LicenseValidationError, p as LicenseValidationRequest, q as LicenseValidationResponse, r as LicenseValidator, s as ProviderCredentials, t as ProviderNotFoundException, u as RateLimitException, v as RemoteEmbeddingConfig, w as RemoteLLMConfig, x as RemoteVectorConfig, y as RenderDecision, z as RenderType, F as RetrievalException, G as Retrivora, H as RetrivoraError, J as RetrivoraErrorCode, K as SDKVersionUnsupportedError, N as SDK_VERSION, O as isTransientError } from './BatchProcessor-C42_RVWO.js';
|
|
4
4
|
import { O as ObservabilityTrace, U as UseRagChatOptions, a as UseRagChatReturn, P as ProjectChatSettings } from './ILLMProvider-B8TAVx3j.js';
|
|
5
5
|
export { A as AuthMode, 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, i as ProjectAiSettings, j as ProjectAuthSettings, k as ProjectBrandingSettings, l as ProjectTelemetrySettings, m as ProjectWidgetSettings, R as RAGConfig, n as RagConfig, o as RagMessage, p as RetrievalConfig, q as RetrievedChunk, T as ThemeMode, r as TokenUsage, s as UIConfig, t as UniversalRagConfig, u as UpsertDocument, V as VectorDBConfig, v as VectorDBProvider, w as VectorMatch, W as WidgetPosition, x as WorkflowConfig, y as createDefaultProjectSettings, z as normalizeProjectSettings, B as projectSettingsToUiConfig } from './ILLMProvider-B8TAVx3j.js';
|
|
6
6
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -351,7 +351,7 @@ function projectSettingsToUiConfig(settings) {
|
|
|
351
351
|
// package.json
|
|
352
352
|
var package_default = {
|
|
353
353
|
name: "@retrivora-ai/rag-engine",
|
|
354
|
-
version: "2.3.
|
|
354
|
+
version: "2.3.8",
|
|
355
355
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
356
356
|
author: "Abhinav Alkuchi",
|
|
357
357
|
license: "UNLICENSED",
|
|
@@ -522,7 +522,12 @@ var ConfigFetcher = class {
|
|
|
522
522
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
523
523
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
524
524
|
CONTROL_PLANE_URL
|
|
525
|
-
].filter((url) =>
|
|
525
|
+
].filter((url) => {
|
|
526
|
+
if (!url) return false;
|
|
527
|
+
const isEnvVar = url === process.env.RETRIVORA_CONTROL_PLANE_URL || url === process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL;
|
|
528
|
+
if (!isEnvVar && (url.includes("localhost") || url.includes("127.0.0.1"))) return false;
|
|
529
|
+
return true;
|
|
530
|
+
}).map((url) => url.replace(/\/$/, ""));
|
|
526
531
|
for (const baseUrl of controlPlaneUrls) {
|
|
527
532
|
try {
|
|
528
533
|
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}`;
|
|
@@ -543,8 +548,7 @@ var ConfigFetcher = class {
|
|
|
543
548
|
isActive: data.isActive,
|
|
544
549
|
expiresAt: data.expiresAt,
|
|
545
550
|
vectorDb: {
|
|
546
|
-
// apiKey
|
|
547
|
-
// The SDK uses local PINECONE_API_KEY if available.
|
|
551
|
+
// Fetch apiKey from credentials API if available, else fallback to empty
|
|
548
552
|
apiKey: data.vectorDb.apiKey || "",
|
|
549
553
|
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
550
554
|
provider: data.vectorDb.provider || "pinecone",
|
|
@@ -576,6 +580,32 @@ var ConfigFetcher = class {
|
|
|
576
580
|
data.projectSettings || data.settings
|
|
577
581
|
)
|
|
578
582
|
};
|
|
583
|
+
if (licenseKey) {
|
|
584
|
+
try {
|
|
585
|
+
const credUrl = `${baseUrl}/api/v1/credentials`;
|
|
586
|
+
const credRes = await fetch(credUrl, {
|
|
587
|
+
method: "POST",
|
|
588
|
+
headers: {
|
|
589
|
+
"Content-Type": "application/json"
|
|
590
|
+
},
|
|
591
|
+
body: JSON.stringify({ licenseKey, projectId: fetchedProjectId })
|
|
592
|
+
});
|
|
593
|
+
if (credRes.ok) {
|
|
594
|
+
const credData = await credRes.json();
|
|
595
|
+
if ((credData == null ? void 0 : credData.success) && (credData == null ? void 0 : credData.credentials)) {
|
|
596
|
+
if (credData.credentials.pineconeApiKey && !config.vectorDb.apiKey) {
|
|
597
|
+
config.vectorDb.apiKey = credData.credentials.pineconeApiKey;
|
|
598
|
+
}
|
|
599
|
+
if (credData.credentials.litellmApiKey) {
|
|
600
|
+
config.llm.apiKey = credData.credentials.litellmApiKey;
|
|
601
|
+
config.embedding.apiKey = credData.credentials.litellmApiKey;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
} catch (e) {
|
|
606
|
+
console.warn("[ConfigFetcher] Failed to fetch credentials:", e);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
579
609
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
580
610
|
return config;
|
|
581
611
|
}
|
|
@@ -610,7 +640,8 @@ function ConfigProvider({
|
|
|
610
640
|
config,
|
|
611
641
|
children
|
|
612
642
|
}) {
|
|
613
|
-
const
|
|
643
|
+
const envProjectId = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_PROJECT_ID || process.env.RETRIVORA_PROJECT_ID : "";
|
|
644
|
+
const projectId = (config == null ? void 0 : config.projectId) || envProjectId || DEFAULT_CONFIG.projectId;
|
|
614
645
|
const projectSettingsInput = config == null ? void 0 : config.projectSettings;
|
|
615
646
|
const autoLoadProjectSettings = config == null ? void 0 : config.autoLoadProjectSettings;
|
|
616
647
|
const licenseKeyInput = config == null ? void 0 : config.licenseKey;
|
|
@@ -3571,30 +3602,18 @@ var LicenseValidationError = class extends RetrivoraError {
|
|
|
3571
3602
|
};
|
|
3572
3603
|
|
|
3573
3604
|
// src/core/LicenseVerifier.ts
|
|
3574
|
-
var
|
|
3575
|
-
|
|
3605
|
+
var _LicenseVerifier = class _LicenseVerifier {
|
|
3606
|
+
// Cache verified license for 5 minutes
|
|
3576
3607
|
/**
|
|
3577
|
-
*
|
|
3608
|
+
* Validates the license key asynchronously by calling the Retrivora backend.
|
|
3578
3609
|
*
|
|
3579
3610
|
* @param licenseKey - Base64url signed JWT license key.
|
|
3580
3611
|
* @param currentProjectId - Project namespace ID.
|
|
3581
|
-
* @param
|
|
3612
|
+
* @param provider - Optional provider for tier checks.
|
|
3582
3613
|
*/
|
|
3583
|
-
static
|
|
3614
|
+
static async verifyAsync(licenseKey, currentProjectId, provider) {
|
|
3584
3615
|
const isProduction = process.env.NODE_ENV === "production";
|
|
3585
3616
|
const now = Date.now();
|
|
3586
|
-
if (licenseKey) {
|
|
3587
|
-
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
3588
|
-
const cached = this.cache.get(cacheKey);
|
|
3589
|
-
if (cached && now - cached.cachedAt < this.CACHE_TTL_MS) {
|
|
3590
|
-
const currentTimestampSec = Math.floor(now / 1e3);
|
|
3591
|
-
if (cached.payload.expiresAt && currentTimestampSec > cached.payload.expiresAt) {
|
|
3592
|
-
this.cache.delete(cacheKey);
|
|
3593
|
-
} else {
|
|
3594
|
-
return cached.payload;
|
|
3595
|
-
}
|
|
3596
|
-
}
|
|
3597
|
-
}
|
|
3598
3617
|
if (!licenseKey) {
|
|
3599
3618
|
if (isProduction) {
|
|
3600
3619
|
throw new ConfigurationException(
|
|
@@ -3611,52 +3630,61 @@ var LicenseVerifier = class {
|
|
|
3611
3630
|
tier: "hobby"
|
|
3612
3631
|
};
|
|
3613
3632
|
}
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
const
|
|
3618
|
-
if (
|
|
3619
|
-
|
|
3620
|
-
}
|
|
3621
|
-
|
|
3622
|
-
const dataToVerify = `${headerB64}.${payloadB64}`;
|
|
3623
|
-
const publicKey = publicKeyOverride != null ? publicKeyOverride : this.PUBLIC_KEY;
|
|
3624
|
-
const signature = Buffer.from(signatureB64, "base64url");
|
|
3625
|
-
const data = Buffer.from(dataToVerify);
|
|
3626
|
-
const isValid = crypto.verify(
|
|
3627
|
-
"sha256",
|
|
3628
|
-
data,
|
|
3629
|
-
publicKey,
|
|
3630
|
-
signature
|
|
3631
|
-
);
|
|
3632
|
-
if (!isValid) {
|
|
3633
|
-
throw new Error("Signature verification failed.");
|
|
3633
|
+
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}`;
|
|
3634
|
+
const cached = this.cache.get(cacheKey);
|
|
3635
|
+
if (cached && now - cached.cachedAt < this.CACHE_TTL_MS) {
|
|
3636
|
+
const currentTimestampSec = Math.floor(now / 1e3);
|
|
3637
|
+
if (cached.payload.expiresAt && currentTimestampSec > cached.payload.expiresAt) {
|
|
3638
|
+
this.cache.delete(cacheKey);
|
|
3639
|
+
} else {
|
|
3640
|
+
return cached.payload;
|
|
3634
3641
|
}
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
if (
|
|
3639
|
-
|
|
3642
|
+
}
|
|
3643
|
+
try {
|
|
3644
|
+
let baseUrl = typeof process !== "undefined" && process.env.RETRIVORA_CONTROL_PLANE_URL ? process.env.RETRIVORA_CONTROL_PLANE_URL : "https://retrivora.com";
|
|
3645
|
+
if (typeof process !== "undefined" && process.env.TELEMETRY_URL) {
|
|
3646
|
+
baseUrl = process.env.TELEMETRY_URL.replace(/\/api\/telemetry\/?$/, "");
|
|
3640
3647
|
}
|
|
3641
|
-
const
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3648
|
+
const endpoint = `${baseUrl}/api/v1/license/validate`;
|
|
3649
|
+
const response = await fetch(endpoint, {
|
|
3650
|
+
method: "POST",
|
|
3651
|
+
headers: {
|
|
3652
|
+
"Content-Type": "application/json",
|
|
3653
|
+
"x-license-key": licenseKey
|
|
3654
|
+
},
|
|
3655
|
+
body: JSON.stringify({
|
|
3656
|
+
licenseKey,
|
|
3657
|
+
projectId: currentProjectId,
|
|
3658
|
+
provider
|
|
3659
|
+
})
|
|
3660
|
+
});
|
|
3661
|
+
if (!response.ok) {
|
|
3662
|
+
let errMessage = `HTTP ${response.status}`;
|
|
3663
|
+
try {
|
|
3664
|
+
const body = await response.json();
|
|
3665
|
+
if (body.message) errMessage = body.message;
|
|
3666
|
+
} catch (e) {
|
|
3667
|
+
}
|
|
3668
|
+
throw new Error(errMessage);
|
|
3646
3669
|
}
|
|
3647
|
-
|
|
3648
|
-
|
|
3670
|
+
const data = await response.json();
|
|
3671
|
+
if (!data.valid) {
|
|
3672
|
+
throw new Error(data.message || "License validation failed by server.");
|
|
3649
3673
|
}
|
|
3650
|
-
|
|
3651
|
-
if (
|
|
3652
|
-
|
|
3653
|
-
`License key has expired. Expiration: ${new Date(
|
|
3654
|
-
payload.expiresAt * 1e3
|
|
3655
|
-
).toDateString()}`
|
|
3656
|
-
);
|
|
3674
|
+
let expiresAtNum = Math.floor(Date.now() / 1e3) + 100 * 365 * 24 * 60 * 60;
|
|
3675
|
+
if (data.expiresAt) {
|
|
3676
|
+
expiresAtNum = Math.floor(new Date(data.expiresAt).getTime() / 1e3);
|
|
3657
3677
|
}
|
|
3678
|
+
const tier = _LicenseVerifier.extractTier(licenseKey);
|
|
3679
|
+
const payload = {
|
|
3680
|
+
projectId: currentProjectId,
|
|
3681
|
+
expiresAt: expiresAtNum,
|
|
3682
|
+
tier,
|
|
3683
|
+
licenseStatus: data.licenseStatus,
|
|
3684
|
+
minimumSupportedVersion: data.minimumSupportedVersion,
|
|
3685
|
+
forceUpgrade: data.forceUpgrade
|
|
3686
|
+
};
|
|
3658
3687
|
if (isProduction && provider) {
|
|
3659
|
-
const tier = (payload.tier || "").toLowerCase();
|
|
3660
3688
|
const normalizedProvider = provider.toLowerCase();
|
|
3661
3689
|
if (tier === "hobby") {
|
|
3662
3690
|
const allowedHobby = ["postgresql", "pgvector", "supabase"];
|
|
@@ -3684,15 +3712,12 @@ var LicenseVerifier = class {
|
|
|
3684
3712
|
}
|
|
3685
3713
|
}
|
|
3686
3714
|
}
|
|
3687
|
-
|
|
3688
|
-
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
3689
|
-
this.cache.set(cacheKey, { payload, cachedAt: now });
|
|
3690
|
-
}
|
|
3715
|
+
this.cache.set(cacheKey, { payload, cachedAt: now });
|
|
3691
3716
|
return payload;
|
|
3692
3717
|
} catch (err) {
|
|
3693
3718
|
const message = err instanceof Error ? err.message : String(err);
|
|
3694
3719
|
throw new ConfigurationException(
|
|
3695
|
-
`[Retrivora SDK] License key validation failed: ${message}`
|
|
3720
|
+
`[Retrivora SDK] License key validation failed via API: ${message}`
|
|
3696
3721
|
);
|
|
3697
3722
|
}
|
|
3698
3723
|
}
|
|
@@ -3761,23 +3786,25 @@ var LicenseVerifier = class {
|
|
|
3761
3786
|
}
|
|
3762
3787
|
}
|
|
3763
3788
|
}
|
|
3789
|
+
static extractTier(licenseKey) {
|
|
3790
|
+
if (!licenseKey) return "hobby";
|
|
3791
|
+
try {
|
|
3792
|
+
const sanitizedKey = licenseKey.trim().replace(/^["']|["']$/g, "").trim();
|
|
3793
|
+
const rawToken = sanitizedKey.replace(/^rtv_/i, "").trim();
|
|
3794
|
+
const parts = rawToken.split(".");
|
|
3795
|
+
if (parts.length === 3) {
|
|
3796
|
+
const decodedPayload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
|
|
3797
|
+
if (decodedPayload.tier) return decodedPayload.tier;
|
|
3798
|
+
}
|
|
3799
|
+
} catch (e) {
|
|
3800
|
+
}
|
|
3801
|
+
return "hobby";
|
|
3802
|
+
}
|
|
3764
3803
|
};
|
|
3765
|
-
//
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
// Retrivora's Public Key used to verify the license key signature.
|
|
3770
|
-
// In production, this matches the private key held by Retrivora SaaS.
|
|
3771
|
-
// Rotate this key only when the signing private key is replaced.
|
|
3772
|
-
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
3773
|
-
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
3774
|
-
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
3775
|
-
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
3776
|
-
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
3777
|
-
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
3778
|
-
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
3779
|
-
gQIDAQAB
|
|
3780
|
-
-----END PUBLIC KEY-----`;
|
|
3804
|
+
// In-memory cache to save network overhead on hot paths.
|
|
3805
|
+
_LicenseVerifier.cache = /* @__PURE__ */ new Map();
|
|
3806
|
+
_LicenseVerifier.CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
3807
|
+
var LicenseVerifier = _LicenseVerifier;
|
|
3781
3808
|
|
|
3782
3809
|
// src/core/LicenseValidator.ts
|
|
3783
3810
|
function canUseLocalValidationFallback(baseUrl, status) {
|
|
@@ -3839,6 +3866,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3839
3866
|
retrivoraApiBase,
|
|
3840
3867
|
headers: customHeaders
|
|
3841
3868
|
} = request;
|
|
3869
|
+
const effectiveProjectId = projectId || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_PROJECT_ID || process.env.RETRIVORA_PROJECT_ID : "") || "";
|
|
3842
3870
|
const getHeader = (name) => {
|
|
3843
3871
|
if (!customHeaders) return void 0;
|
|
3844
3872
|
const target = name.toLowerCase();
|
|
@@ -3876,7 +3904,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3876
3904
|
}, customHeaders || {}),
|
|
3877
3905
|
body: JSON.stringify({
|
|
3878
3906
|
licenseKey: effectiveLicenseKey,
|
|
3879
|
-
projectId,
|
|
3907
|
+
projectId: effectiveProjectId,
|
|
3880
3908
|
sdkVersion,
|
|
3881
3909
|
sdk,
|
|
3882
3910
|
platform
|
|
@@ -3887,7 +3915,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3887
3915
|
if (!canUseLocalValidationFallback(base)) {
|
|
3888
3916
|
throw err;
|
|
3889
3917
|
}
|
|
3890
|
-
const payload = LicenseVerifier.
|
|
3918
|
+
const payload = await LicenseVerifier.verifyAsync(effectiveLicenseKey, effectiveProjectId);
|
|
3891
3919
|
const fallbackResp = {
|
|
3892
3920
|
valid: true,
|
|
3893
3921
|
licenseStatus: "ACTIVE",
|
|
@@ -3906,7 +3934,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3906
3934
|
}
|
|
3907
3935
|
if (res && !res.ok && canUseLocalValidationFallback(base, res.status)) {
|
|
3908
3936
|
try {
|
|
3909
|
-
const payload = LicenseVerifier.
|
|
3937
|
+
const payload = await LicenseVerifier.verifyAsync(effectiveLicenseKey, effectiveProjectId);
|
|
3910
3938
|
const fallbackResp = {
|
|
3911
3939
|
valid: true,
|
|
3912
3940
|
licenseStatus: "ACTIVE",
|
|
@@ -4688,7 +4716,6 @@ function ChatWidget({ position, onAddToCart, apiUrl, retrivoraApiBase, licenseKe
|
|
|
4688
4716
|
"button",
|
|
4689
4717
|
{
|
|
4690
4718
|
onClick: isOpen ? () => setIsOpen(false) : handleOpen,
|
|
4691
|
-
disabled: isWidgetLocked && !isOpen,
|
|
4692
4719
|
"aria-label": isWidgetLocked ? "Chat unavailable - invalid or missing license key" : isOpen ? "Close chat" : "Open chat",
|
|
4693
4720
|
"aria-disabled": isWidgetLocked && !isOpen,
|
|
4694
4721
|
className: `group fixed z-[9999] w-14 h-14 drop-shadow-2xl flex items-center justify-center transition-all duration-300 ${positionClass} ${isWidgetLocked && !isOpen ? "grayscale opacity-60 cursor-not-allowed" : "cursor-pointer hover:scale-110 active:scale-95"}`,
|