@retrivora-ai/rag-engine 2.3.3 → 2.3.5
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/handlers/index.js +60 -27
- package/dist/handlers/index.mjs +60 -27
- package/dist/index.js +24 -10
- package/dist/index.mjs +24 -10
- package/dist/server.js +71 -29
- package/dist/server.mjs +71 -29
- package/package.json +2 -2
- package/src/core/ConfigFetcher.ts +64 -11
- package/src/core/LicenseValidator.ts +19 -10
- package/src/core/LicenseVerifier.ts +12 -7
- package/src/handlers/index.ts +2 -2
- package/src/providers/vectordb/PineconeProvider.ts +17 -4
package/dist/handlers/index.js
CHANGED
|
@@ -155,14 +155,26 @@ var init_BaseVectorProvider = __esm({
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
// src/core/ConfigFetcher.ts
|
|
158
|
-
var ConfigFetcher;
|
|
158
|
+
var CONTROL_PLANE_URL, LLM_PROXY_BASE_URL, ConfigFetcher;
|
|
159
159
|
var init_ConfigFetcher = __esm({
|
|
160
160
|
"src/core/ConfigFetcher.ts"() {
|
|
161
161
|
"use strict";
|
|
162
|
+
CONTROL_PLANE_URL = "https://www.retrivora.com";
|
|
163
|
+
LLM_PROXY_BASE_URL = "https://www.retrivora.com/api/v1";
|
|
162
164
|
ConfigFetcher = class {
|
|
163
165
|
// 5-minute in-memory session cache
|
|
164
166
|
/**
|
|
165
|
-
* Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
|
|
167
|
+
* Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
|
|
168
|
+
*
|
|
169
|
+
* The SDK calls https://www.retrivora.com/api/v1/config with the project ID and license key.
|
|
170
|
+
* The server validates the license against the database and returns:
|
|
171
|
+
* - validity (tier, isActive, expiresAt)
|
|
172
|
+
* - LLM model info
|
|
173
|
+
* - embedding model info
|
|
174
|
+
* - Pinecone index name and workspace/namespace
|
|
175
|
+
*
|
|
176
|
+
* The Pinecone API key is NOT returned (server-only). The SDK uses local
|
|
177
|
+
* PINECONE_API_KEY if available, or vector operations are handled server-side.
|
|
166
178
|
*/
|
|
167
179
|
static async fetchRemoteConfig(projectId, licenseKey) {
|
|
168
180
|
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
@@ -175,14 +187,11 @@ var init_ConfigFetcher = __esm({
|
|
|
175
187
|
const controlPlaneUrls = [
|
|
176
188
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
177
189
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"http://localhost:3000",
|
|
181
|
-
"http://localhost:3001"
|
|
182
|
-
].filter(Boolean);
|
|
190
|
+
CONTROL_PLANE_URL
|
|
191
|
+
].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
|
|
183
192
|
for (const baseUrl of controlPlaneUrls) {
|
|
184
193
|
try {
|
|
185
|
-
const url = `${baseUrl
|
|
194
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ""}`;
|
|
186
195
|
const res = await fetch(url, {
|
|
187
196
|
method: "GET",
|
|
188
197
|
headers: __spreadValues({
|
|
@@ -191,29 +200,41 @@ var init_ConfigFetcher = __esm({
|
|
|
191
200
|
});
|
|
192
201
|
if (res.ok) {
|
|
193
202
|
const data = await res.json();
|
|
194
|
-
if ((data == null ? void 0 : data.success) && (
|
|
203
|
+
if ((data == null ? void 0 : data.success) && (data == null ? void 0 : data.vectorDb)) {
|
|
195
204
|
const fetchedProjectId = data.projectId || projectId;
|
|
196
205
|
const config = {
|
|
197
206
|
projectId: fetchedProjectId,
|
|
207
|
+
tier: data.tier,
|
|
208
|
+
isActive: data.isActive,
|
|
209
|
+
expiresAt: data.expiresAt,
|
|
198
210
|
vectorDb: {
|
|
199
|
-
apiKey
|
|
211
|
+
// apiKey is not returned by the config API — it's a server-only secret.
|
|
212
|
+
// The SDK uses local PINECONE_API_KEY if available.
|
|
213
|
+
apiKey: data.vectorDb.apiKey || "",
|
|
200
214
|
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
201
215
|
provider: data.vectorDb.provider || "pinecone",
|
|
202
|
-
projectId: fetchedProjectId
|
|
216
|
+
projectId: fetchedProjectId,
|
|
217
|
+
namespace: ((_a3 = data.workspace) == null ? void 0 : _a3.namespace) || data.vectorDb.namespace || fetchedProjectId
|
|
203
218
|
},
|
|
204
219
|
embedding: {
|
|
205
220
|
provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
|
|
206
221
|
model: ((_c = data.embedding) == null ? void 0 : _c.model) || "text-embedding-004",
|
|
207
|
-
|
|
222
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
223
|
+
baseUrl: ((_d = data.embedding) == null ? void 0 : _d.baseUrl) || LLM_PROXY_BASE_URL,
|
|
208
224
|
apiKey: ((_e = data.embedding) == null ? void 0 : _e.apiKey) || licenseKey || "",
|
|
209
225
|
profile: ((_f = data.embedding) == null ? void 0 : _f.profile) || "litellm"
|
|
210
226
|
},
|
|
211
227
|
llm: {
|
|
212
228
|
provider: ((_g2 = data.llm) == null ? void 0 : _g2.provider) || "universal_rest",
|
|
213
229
|
model: ((_h = data.llm) == null ? void 0 : _h.model) || "llama-3.1-8b-instant",
|
|
214
|
-
|
|
230
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
231
|
+
baseUrl: ((_i = data.llm) == null ? void 0 : _i.baseUrl) || LLM_PROXY_BASE_URL,
|
|
215
232
|
apiKey: ((_j = data.llm) == null ? void 0 : _j.apiKey) || licenseKey || "",
|
|
216
233
|
profile: ((_k = data.llm) == null ? void 0 : _k.profile) || "litellm"
|
|
234
|
+
},
|
|
235
|
+
workspace: data.workspace || {
|
|
236
|
+
namespace: fetchedProjectId,
|
|
237
|
+
indexName: data.vectorDb.indexName || "retrivora-free"
|
|
217
238
|
}
|
|
218
239
|
};
|
|
219
240
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
@@ -332,19 +353,26 @@ var init_PineconeProvider = __esm({
|
|
|
332
353
|
})();
|
|
333
354
|
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || "default";
|
|
334
355
|
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
335
|
-
if (remoteConfig
|
|
336
|
-
|
|
337
|
-
|
|
356
|
+
if (remoteConfig) {
|
|
357
|
+
if (remoteConfig.apiKey) {
|
|
358
|
+
key = remoteConfig.apiKey;
|
|
359
|
+
this.apiKey = key;
|
|
360
|
+
}
|
|
338
361
|
if (remoteConfig.indexName) {
|
|
339
362
|
this.indexName = remoteConfig.indexName;
|
|
340
363
|
}
|
|
341
364
|
if (remoteConfig.projectId) {
|
|
342
365
|
this.projectId = remoteConfig.projectId;
|
|
343
366
|
}
|
|
367
|
+
if (remoteConfig.namespace) {
|
|
368
|
+
this.namespace = remoteConfig.namespace;
|
|
369
|
+
}
|
|
344
370
|
}
|
|
345
371
|
}
|
|
346
372
|
if (!key) {
|
|
347
|
-
console.warn(
|
|
373
|
+
console.warn(
|
|
374
|
+
"[PineconeProvider] Warning: No Pinecone API key available. Set PINECONE_API_KEY in your environment, or ensure the Retrivora Control Plane (https://www.retrivora.com) is reachable for proxy-based vector operations."
|
|
375
|
+
);
|
|
348
376
|
return;
|
|
349
377
|
}
|
|
350
378
|
this.client = new import_pinecone.Pinecone({ apiKey: key });
|
|
@@ -2314,6 +2342,10 @@ var LicenseVerifier = class {
|
|
|
2314
2342
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
2315
2343
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2316
2344
|
const now = Date.now();
|
|
2345
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
2346
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
2347
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
2348
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
2317
2349
|
if (licenseKey) {
|
|
2318
2350
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
2319
2351
|
const cached = this.cache.get(cacheKey);
|
|
@@ -2499,14 +2531,15 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
2499
2531
|
// Cache verified license for 60 seconds
|
|
2500
2532
|
// Retrivora's Public Key used to verify the license key signature.
|
|
2501
2533
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
2534
|
+
// Rotate this key only when the signing private key is replaced.
|
|
2502
2535
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
+
|
|
2509
|
-
|
|
2536
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
2537
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
2538
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
2539
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
2540
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
2541
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
2542
|
+
gQIDAQAB
|
|
2510
2543
|
-----END PUBLIC KEY-----`;
|
|
2511
2544
|
|
|
2512
2545
|
// src/config/constants.ts
|
|
@@ -4708,7 +4741,7 @@ var ConfigValidator = class {
|
|
|
4708
4741
|
// package.json
|
|
4709
4742
|
var package_default = {
|
|
4710
4743
|
name: "@retrivora-ai/rag-engine",
|
|
4711
|
-
version: "2.3.
|
|
4744
|
+
version: "2.3.5",
|
|
4712
4745
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4713
4746
|
author: "Abhinav Alkuchi",
|
|
4714
4747
|
license: "UNLICENSED",
|
|
@@ -10625,7 +10658,7 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
|
|
|
10625
10658
|
function enforceLicense(req, config, bodyLicenseKey) {
|
|
10626
10659
|
const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
|
|
10627
10660
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
10628
|
-
const projectId = config.projectId || "
|
|
10661
|
+
const projectId = config.projectId || "";
|
|
10629
10662
|
try {
|
|
10630
10663
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
10631
10664
|
return { ok: true, payload };
|
|
@@ -11101,7 +11134,7 @@ function createLicenseHandler(configOrPlugin, options) {
|
|
|
11101
11134
|
const config = plugin.getConfig();
|
|
11102
11135
|
const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
|
|
11103
11136
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
11104
|
-
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "
|
|
11137
|
+
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
|
|
11105
11138
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
11106
11139
|
return import_server.NextResponse.json({
|
|
11107
11140
|
valid: true,
|
package/dist/handlers/index.mjs
CHANGED
|
@@ -140,14 +140,26 @@ var init_BaseVectorProvider = __esm({
|
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
// src/core/ConfigFetcher.ts
|
|
143
|
-
var ConfigFetcher;
|
|
143
|
+
var CONTROL_PLANE_URL, LLM_PROXY_BASE_URL, ConfigFetcher;
|
|
144
144
|
var init_ConfigFetcher = __esm({
|
|
145
145
|
"src/core/ConfigFetcher.ts"() {
|
|
146
146
|
"use strict";
|
|
147
|
+
CONTROL_PLANE_URL = "https://www.retrivora.com";
|
|
148
|
+
LLM_PROXY_BASE_URL = "https://www.retrivora.com/api/v1";
|
|
147
149
|
ConfigFetcher = class {
|
|
148
150
|
// 5-minute in-memory session cache
|
|
149
151
|
/**
|
|
150
|
-
* Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
|
|
152
|
+
* Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
|
|
153
|
+
*
|
|
154
|
+
* The SDK calls https://www.retrivora.com/api/v1/config with the project ID and license key.
|
|
155
|
+
* The server validates the license against the database and returns:
|
|
156
|
+
* - validity (tier, isActive, expiresAt)
|
|
157
|
+
* - LLM model info
|
|
158
|
+
* - embedding model info
|
|
159
|
+
* - Pinecone index name and workspace/namespace
|
|
160
|
+
*
|
|
161
|
+
* The Pinecone API key is NOT returned (server-only). The SDK uses local
|
|
162
|
+
* PINECONE_API_KEY if available, or vector operations are handled server-side.
|
|
151
163
|
*/
|
|
152
164
|
static async fetchRemoteConfig(projectId, licenseKey) {
|
|
153
165
|
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
@@ -160,14 +172,11 @@ var init_ConfigFetcher = __esm({
|
|
|
160
172
|
const controlPlaneUrls = [
|
|
161
173
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
162
174
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"http://localhost:3000",
|
|
166
|
-
"http://localhost:3001"
|
|
167
|
-
].filter(Boolean);
|
|
175
|
+
CONTROL_PLANE_URL
|
|
176
|
+
].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
|
|
168
177
|
for (const baseUrl of controlPlaneUrls) {
|
|
169
178
|
try {
|
|
170
|
-
const url = `${baseUrl
|
|
179
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ""}`;
|
|
171
180
|
const res = await fetch(url, {
|
|
172
181
|
method: "GET",
|
|
173
182
|
headers: __spreadValues({
|
|
@@ -176,29 +185,41 @@ var init_ConfigFetcher = __esm({
|
|
|
176
185
|
});
|
|
177
186
|
if (res.ok) {
|
|
178
187
|
const data = await res.json();
|
|
179
|
-
if ((data == null ? void 0 : data.success) && (
|
|
188
|
+
if ((data == null ? void 0 : data.success) && (data == null ? void 0 : data.vectorDb)) {
|
|
180
189
|
const fetchedProjectId = data.projectId || projectId;
|
|
181
190
|
const config = {
|
|
182
191
|
projectId: fetchedProjectId,
|
|
192
|
+
tier: data.tier,
|
|
193
|
+
isActive: data.isActive,
|
|
194
|
+
expiresAt: data.expiresAt,
|
|
183
195
|
vectorDb: {
|
|
184
|
-
apiKey
|
|
196
|
+
// apiKey is not returned by the config API — it's a server-only secret.
|
|
197
|
+
// The SDK uses local PINECONE_API_KEY if available.
|
|
198
|
+
apiKey: data.vectorDb.apiKey || "",
|
|
185
199
|
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
186
200
|
provider: data.vectorDb.provider || "pinecone",
|
|
187
|
-
projectId: fetchedProjectId
|
|
201
|
+
projectId: fetchedProjectId,
|
|
202
|
+
namespace: ((_a3 = data.workspace) == null ? void 0 : _a3.namespace) || data.vectorDb.namespace || fetchedProjectId
|
|
188
203
|
},
|
|
189
204
|
embedding: {
|
|
190
205
|
provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
|
|
191
206
|
model: ((_c = data.embedding) == null ? void 0 : _c.model) || "text-embedding-004",
|
|
192
|
-
|
|
207
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
208
|
+
baseUrl: ((_d = data.embedding) == null ? void 0 : _d.baseUrl) || LLM_PROXY_BASE_URL,
|
|
193
209
|
apiKey: ((_e = data.embedding) == null ? void 0 : _e.apiKey) || licenseKey || "",
|
|
194
210
|
profile: ((_f = data.embedding) == null ? void 0 : _f.profile) || "litellm"
|
|
195
211
|
},
|
|
196
212
|
llm: {
|
|
197
213
|
provider: ((_g2 = data.llm) == null ? void 0 : _g2.provider) || "universal_rest",
|
|
198
214
|
model: ((_h = data.llm) == null ? void 0 : _h.model) || "llama-3.1-8b-instant",
|
|
199
|
-
|
|
215
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
216
|
+
baseUrl: ((_i = data.llm) == null ? void 0 : _i.baseUrl) || LLM_PROXY_BASE_URL,
|
|
200
217
|
apiKey: ((_j = data.llm) == null ? void 0 : _j.apiKey) || licenseKey || "",
|
|
201
218
|
profile: ((_k = data.llm) == null ? void 0 : _k.profile) || "litellm"
|
|
219
|
+
},
|
|
220
|
+
workspace: data.workspace || {
|
|
221
|
+
namespace: fetchedProjectId,
|
|
222
|
+
indexName: data.vectorDb.indexName || "retrivora-free"
|
|
202
223
|
}
|
|
203
224
|
};
|
|
204
225
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
@@ -317,19 +338,26 @@ var init_PineconeProvider = __esm({
|
|
|
317
338
|
})();
|
|
318
339
|
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || "default";
|
|
319
340
|
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
320
|
-
if (remoteConfig
|
|
321
|
-
|
|
322
|
-
|
|
341
|
+
if (remoteConfig) {
|
|
342
|
+
if (remoteConfig.apiKey) {
|
|
343
|
+
key = remoteConfig.apiKey;
|
|
344
|
+
this.apiKey = key;
|
|
345
|
+
}
|
|
323
346
|
if (remoteConfig.indexName) {
|
|
324
347
|
this.indexName = remoteConfig.indexName;
|
|
325
348
|
}
|
|
326
349
|
if (remoteConfig.projectId) {
|
|
327
350
|
this.projectId = remoteConfig.projectId;
|
|
328
351
|
}
|
|
352
|
+
if (remoteConfig.namespace) {
|
|
353
|
+
this.namespace = remoteConfig.namespace;
|
|
354
|
+
}
|
|
329
355
|
}
|
|
330
356
|
}
|
|
331
357
|
if (!key) {
|
|
332
|
-
console.warn(
|
|
358
|
+
console.warn(
|
|
359
|
+
"[PineconeProvider] Warning: No Pinecone API key available. Set PINECONE_API_KEY in your environment, or ensure the Retrivora Control Plane (https://www.retrivora.com) is reachable for proxy-based vector operations."
|
|
360
|
+
);
|
|
333
361
|
return;
|
|
334
362
|
}
|
|
335
363
|
this.client = new Pinecone({ apiKey: key });
|
|
@@ -2278,6 +2306,10 @@ var LicenseVerifier = class {
|
|
|
2278
2306
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
2279
2307
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2280
2308
|
const now = Date.now();
|
|
2309
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
2310
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
2311
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
2312
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
2281
2313
|
if (licenseKey) {
|
|
2282
2314
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
2283
2315
|
const cached = this.cache.get(cacheKey);
|
|
@@ -2463,14 +2495,15 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
2463
2495
|
// Cache verified license for 60 seconds
|
|
2464
2496
|
// Retrivora's Public Key used to verify the license key signature.
|
|
2465
2497
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
2498
|
+
// Rotate this key only when the signing private key is replaced.
|
|
2466
2499
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
+
|
|
2473
|
-
|
|
2500
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
2501
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
2502
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
2503
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
2504
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
2505
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
2506
|
+
gQIDAQAB
|
|
2474
2507
|
-----END PUBLIC KEY-----`;
|
|
2475
2508
|
|
|
2476
2509
|
// src/config/constants.ts
|
|
@@ -4672,7 +4705,7 @@ var ConfigValidator = class {
|
|
|
4672
4705
|
// package.json
|
|
4673
4706
|
var package_default = {
|
|
4674
4707
|
name: "@retrivora-ai/rag-engine",
|
|
4675
|
-
version: "2.3.
|
|
4708
|
+
version: "2.3.5",
|
|
4676
4709
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4677
4710
|
author: "Abhinav Alkuchi",
|
|
4678
4711
|
license: "UNLICENSED",
|
|
@@ -10589,7 +10622,7 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
|
|
|
10589
10622
|
function enforceLicense(req, config, bodyLicenseKey) {
|
|
10590
10623
|
const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
|
|
10591
10624
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
10592
|
-
const projectId = config.projectId || "
|
|
10625
|
+
const projectId = config.projectId || "";
|
|
10593
10626
|
try {
|
|
10594
10627
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
10595
10628
|
return { ok: true, payload };
|
|
@@ -11065,7 +11098,7 @@ function createLicenseHandler(configOrPlugin, options) {
|
|
|
11065
11098
|
const config = plugin.getConfig();
|
|
11066
11099
|
const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
|
|
11067
11100
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
11068
|
-
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "
|
|
11101
|
+
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
|
|
11069
11102
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
11070
11103
|
return NextResponse.json({
|
|
11071
11104
|
valid: true,
|
package/dist/index.js
CHANGED
|
@@ -3042,7 +3042,7 @@ function useRagChat(projectId, options = {}) {
|
|
|
3042
3042
|
// package.json
|
|
3043
3043
|
var package_default = {
|
|
3044
3044
|
name: "@retrivora-ai/rag-engine",
|
|
3045
|
-
version: "2.3.
|
|
3045
|
+
version: "2.3.5",
|
|
3046
3046
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
3047
3047
|
author: "Abhinav Alkuchi",
|
|
3048
3048
|
license: "UNLICENSED",
|
|
@@ -3246,6 +3246,10 @@ var LicenseVerifier = class {
|
|
|
3246
3246
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
3247
3247
|
const isProduction = process.env.NODE_ENV === "production";
|
|
3248
3248
|
const now = Date.now();
|
|
3249
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
3250
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
3251
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
3252
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
3249
3253
|
if (licenseKey) {
|
|
3250
3254
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
3251
3255
|
const cached = this.cache.get(cacheKey);
|
|
@@ -3431,14 +3435,15 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
3431
3435
|
// Cache verified license for 60 seconds
|
|
3432
3436
|
// Retrivora's Public Key used to verify the license key signature.
|
|
3433
3437
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
3438
|
+
// Rotate this key only when the signing private key is replaced.
|
|
3434
3439
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
+
|
|
3441
|
-
|
|
3440
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
3441
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
3442
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
3443
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
3444
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
3445
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
3446
|
+
gQIDAQAB
|
|
3442
3447
|
-----END PUBLIC KEY-----`;
|
|
3443
3448
|
|
|
3444
3449
|
// src/core/LicenseValidator.ts
|
|
@@ -3501,8 +3506,17 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3501
3506
|
}
|
|
3502
3507
|
return void 0;
|
|
3503
3508
|
};
|
|
3509
|
+
console.log("LicenseValidator.validate()", request);
|
|
3510
|
+
console.log("LicenseValidator.validate() - licenseKey", licenseKey);
|
|
3511
|
+
console.log("LicenseValidator.validate() - projectId", projectId);
|
|
3512
|
+
console.log("LicenseValidator.validate() - sdkVersion", sdkVersion);
|
|
3513
|
+
console.log("LicenseValidator.validate() - sdk", sdk);
|
|
3514
|
+
console.log("LicenseValidator.validate() - platform", platform);
|
|
3515
|
+
console.log("LicenseValidator.validate() - retrivoraApiBase", retrivoraApiBase);
|
|
3516
|
+
console.log("LicenseValidator.validate() - customHeaders", customHeaders);
|
|
3504
3517
|
const rawKey = licenseKey || getHeader("x-license-key") || ((_a = getHeader("authorization")) == null ? void 0 : _a.replace(/^Bearer\s+/i, "")) || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY : "") || "";
|
|
3505
3518
|
const effectiveLicenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
3519
|
+
console.log("LicenseValidator.validate() - effectiveLicenseKey", effectiveLicenseKey);
|
|
3506
3520
|
if (!effectiveLicenseKey) {
|
|
3507
3521
|
this.purgeCache(effectiveLicenseKey);
|
|
3508
3522
|
throw new LicenseValidationError("Missing RETRIVORA_LICENSE_KEY in request. Set NEXT_PUBLIC_RETRIVORA_LICENSE_KEY in your environment or pass licenseKey as a prop.");
|
|
@@ -3538,7 +3552,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3538
3552
|
});
|
|
3539
3553
|
} catch (err) {
|
|
3540
3554
|
try {
|
|
3541
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
3555
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
3542
3556
|
const fallbackResp = {
|
|
3543
3557
|
valid: true,
|
|
3544
3558
|
licenseStatus: "ACTIVE",
|
|
@@ -3557,7 +3571,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3557
3571
|
}
|
|
3558
3572
|
if (res && !res.ok) {
|
|
3559
3573
|
try {
|
|
3560
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
3574
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
3561
3575
|
const fallbackResp = {
|
|
3562
3576
|
valid: true,
|
|
3563
3577
|
licenseStatus: "ACTIVE",
|
package/dist/index.mjs
CHANGED
|
@@ -3049,7 +3049,7 @@ function useRagChat(projectId, options = {}) {
|
|
|
3049
3049
|
// package.json
|
|
3050
3050
|
var package_default = {
|
|
3051
3051
|
name: "@retrivora-ai/rag-engine",
|
|
3052
|
-
version: "2.3.
|
|
3052
|
+
version: "2.3.5",
|
|
3053
3053
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
3054
3054
|
author: "Abhinav Alkuchi",
|
|
3055
3055
|
license: "UNLICENSED",
|
|
@@ -3253,6 +3253,10 @@ var LicenseVerifier = class {
|
|
|
3253
3253
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
3254
3254
|
const isProduction = process.env.NODE_ENV === "production";
|
|
3255
3255
|
const now = Date.now();
|
|
3256
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
3257
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
3258
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
3259
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
3256
3260
|
if (licenseKey) {
|
|
3257
3261
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
3258
3262
|
const cached = this.cache.get(cacheKey);
|
|
@@ -3438,14 +3442,15 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
3438
3442
|
// Cache verified license for 60 seconds
|
|
3439
3443
|
// Retrivora's Public Key used to verify the license key signature.
|
|
3440
3444
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
3445
|
+
// Rotate this key only when the signing private key is replaced.
|
|
3441
3446
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
+
|
|
3448
|
-
|
|
3447
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
3448
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
3449
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
3450
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
3451
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
3452
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
3453
|
+
gQIDAQAB
|
|
3449
3454
|
-----END PUBLIC KEY-----`;
|
|
3450
3455
|
|
|
3451
3456
|
// src/core/LicenseValidator.ts
|
|
@@ -3508,8 +3513,17 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3508
3513
|
}
|
|
3509
3514
|
return void 0;
|
|
3510
3515
|
};
|
|
3516
|
+
console.log("LicenseValidator.validate()", request);
|
|
3517
|
+
console.log("LicenseValidator.validate() - licenseKey", licenseKey);
|
|
3518
|
+
console.log("LicenseValidator.validate() - projectId", projectId);
|
|
3519
|
+
console.log("LicenseValidator.validate() - sdkVersion", sdkVersion);
|
|
3520
|
+
console.log("LicenseValidator.validate() - sdk", sdk);
|
|
3521
|
+
console.log("LicenseValidator.validate() - platform", platform);
|
|
3522
|
+
console.log("LicenseValidator.validate() - retrivoraApiBase", retrivoraApiBase);
|
|
3523
|
+
console.log("LicenseValidator.validate() - customHeaders", customHeaders);
|
|
3511
3524
|
const rawKey = licenseKey || getHeader("x-license-key") || ((_a = getHeader("authorization")) == null ? void 0 : _a.replace(/^Bearer\s+/i, "")) || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY : "") || "";
|
|
3512
3525
|
const effectiveLicenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
3526
|
+
console.log("LicenseValidator.validate() - effectiveLicenseKey", effectiveLicenseKey);
|
|
3513
3527
|
if (!effectiveLicenseKey) {
|
|
3514
3528
|
this.purgeCache(effectiveLicenseKey);
|
|
3515
3529
|
throw new LicenseValidationError("Missing RETRIVORA_LICENSE_KEY in request. Set NEXT_PUBLIC_RETRIVORA_LICENSE_KEY in your environment or pass licenseKey as a prop.");
|
|
@@ -3545,7 +3559,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3545
3559
|
});
|
|
3546
3560
|
} catch (err) {
|
|
3547
3561
|
try {
|
|
3548
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
3562
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
3549
3563
|
const fallbackResp = {
|
|
3550
3564
|
valid: true,
|
|
3551
3565
|
licenseStatus: "ACTIVE",
|
|
@@ -3564,7 +3578,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
3564
3578
|
}
|
|
3565
3579
|
if (res && !res.ok) {
|
|
3566
3580
|
try {
|
|
3567
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
3581
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
3568
3582
|
const fallbackResp = {
|
|
3569
3583
|
valid: true,
|
|
3570
3584
|
licenseStatus: "ACTIVE",
|
package/dist/server.js
CHANGED
|
@@ -155,14 +155,26 @@ var init_BaseVectorProvider = __esm({
|
|
|
155
155
|
});
|
|
156
156
|
|
|
157
157
|
// src/core/ConfigFetcher.ts
|
|
158
|
-
var ConfigFetcher;
|
|
158
|
+
var CONTROL_PLANE_URL, LLM_PROXY_BASE_URL, ConfigFetcher;
|
|
159
159
|
var init_ConfigFetcher = __esm({
|
|
160
160
|
"src/core/ConfigFetcher.ts"() {
|
|
161
161
|
"use strict";
|
|
162
|
+
CONTROL_PLANE_URL = "https://www.retrivora.com";
|
|
163
|
+
LLM_PROXY_BASE_URL = "https://www.retrivora.com/api/v1";
|
|
162
164
|
ConfigFetcher = class {
|
|
163
165
|
// 5-minute in-memory session cache
|
|
164
166
|
/**
|
|
165
|
-
* Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
|
|
167
|
+
* Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
|
|
168
|
+
*
|
|
169
|
+
* The SDK calls https://www.retrivora.com/api/v1/config with the project ID and license key.
|
|
170
|
+
* The server validates the license against the database and returns:
|
|
171
|
+
* - validity (tier, isActive, expiresAt)
|
|
172
|
+
* - LLM model info
|
|
173
|
+
* - embedding model info
|
|
174
|
+
* - Pinecone index name and workspace/namespace
|
|
175
|
+
*
|
|
176
|
+
* The Pinecone API key is NOT returned (server-only). The SDK uses local
|
|
177
|
+
* PINECONE_API_KEY if available, or vector operations are handled server-side.
|
|
166
178
|
*/
|
|
167
179
|
static async fetchRemoteConfig(projectId, licenseKey) {
|
|
168
180
|
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
@@ -175,14 +187,11 @@ var init_ConfigFetcher = __esm({
|
|
|
175
187
|
const controlPlaneUrls = [
|
|
176
188
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
177
189
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"http://localhost:3000",
|
|
181
|
-
"http://localhost:3001"
|
|
182
|
-
].filter(Boolean);
|
|
190
|
+
CONTROL_PLANE_URL
|
|
191
|
+
].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
|
|
183
192
|
for (const baseUrl of controlPlaneUrls) {
|
|
184
193
|
try {
|
|
185
|
-
const url = `${baseUrl
|
|
194
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ""}`;
|
|
186
195
|
const res = await fetch(url, {
|
|
187
196
|
method: "GET",
|
|
188
197
|
headers: __spreadValues({
|
|
@@ -191,29 +200,41 @@ var init_ConfigFetcher = __esm({
|
|
|
191
200
|
});
|
|
192
201
|
if (res.ok) {
|
|
193
202
|
const data = await res.json();
|
|
194
|
-
if ((data == null ? void 0 : data.success) && (
|
|
203
|
+
if ((data == null ? void 0 : data.success) && (data == null ? void 0 : data.vectorDb)) {
|
|
195
204
|
const fetchedProjectId = data.projectId || projectId;
|
|
196
205
|
const config = {
|
|
197
206
|
projectId: fetchedProjectId,
|
|
207
|
+
tier: data.tier,
|
|
208
|
+
isActive: data.isActive,
|
|
209
|
+
expiresAt: data.expiresAt,
|
|
198
210
|
vectorDb: {
|
|
199
|
-
apiKey
|
|
211
|
+
// apiKey is not returned by the config API — it's a server-only secret.
|
|
212
|
+
// The SDK uses local PINECONE_API_KEY if available.
|
|
213
|
+
apiKey: data.vectorDb.apiKey || "",
|
|
200
214
|
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
201
215
|
provider: data.vectorDb.provider || "pinecone",
|
|
202
|
-
projectId: fetchedProjectId
|
|
216
|
+
projectId: fetchedProjectId,
|
|
217
|
+
namespace: ((_a3 = data.workspace) == null ? void 0 : _a3.namespace) || data.vectorDb.namespace || fetchedProjectId
|
|
203
218
|
},
|
|
204
219
|
embedding: {
|
|
205
220
|
provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
|
|
206
221
|
model: ((_c = data.embedding) == null ? void 0 : _c.model) || "text-embedding-004",
|
|
207
|
-
|
|
222
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
223
|
+
baseUrl: ((_d = data.embedding) == null ? void 0 : _d.baseUrl) || LLM_PROXY_BASE_URL,
|
|
208
224
|
apiKey: ((_e = data.embedding) == null ? void 0 : _e.apiKey) || licenseKey || "",
|
|
209
225
|
profile: ((_f = data.embedding) == null ? void 0 : _f.profile) || "litellm"
|
|
210
226
|
},
|
|
211
227
|
llm: {
|
|
212
228
|
provider: ((_g2 = data.llm) == null ? void 0 : _g2.provider) || "universal_rest",
|
|
213
229
|
model: ((_h = data.llm) == null ? void 0 : _h.model) || "llama-3.1-8b-instant",
|
|
214
|
-
|
|
230
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
231
|
+
baseUrl: ((_i = data.llm) == null ? void 0 : _i.baseUrl) || LLM_PROXY_BASE_URL,
|
|
215
232
|
apiKey: ((_j = data.llm) == null ? void 0 : _j.apiKey) || licenseKey || "",
|
|
216
233
|
profile: ((_k = data.llm) == null ? void 0 : _k.profile) || "litellm"
|
|
234
|
+
},
|
|
235
|
+
workspace: data.workspace || {
|
|
236
|
+
namespace: fetchedProjectId,
|
|
237
|
+
indexName: data.vectorDb.indexName || "retrivora-free"
|
|
217
238
|
}
|
|
218
239
|
};
|
|
219
240
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
@@ -332,19 +353,26 @@ var init_PineconeProvider = __esm({
|
|
|
332
353
|
})();
|
|
333
354
|
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || "default";
|
|
334
355
|
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
335
|
-
if (remoteConfig
|
|
336
|
-
|
|
337
|
-
|
|
356
|
+
if (remoteConfig) {
|
|
357
|
+
if (remoteConfig.apiKey) {
|
|
358
|
+
key = remoteConfig.apiKey;
|
|
359
|
+
this.apiKey = key;
|
|
360
|
+
}
|
|
338
361
|
if (remoteConfig.indexName) {
|
|
339
362
|
this.indexName = remoteConfig.indexName;
|
|
340
363
|
}
|
|
341
364
|
if (remoteConfig.projectId) {
|
|
342
365
|
this.projectId = remoteConfig.projectId;
|
|
343
366
|
}
|
|
367
|
+
if (remoteConfig.namespace) {
|
|
368
|
+
this.namespace = remoteConfig.namespace;
|
|
369
|
+
}
|
|
344
370
|
}
|
|
345
371
|
}
|
|
346
372
|
if (!key) {
|
|
347
|
-
console.warn(
|
|
373
|
+
console.warn(
|
|
374
|
+
"[PineconeProvider] Warning: No Pinecone API key available. Set PINECONE_API_KEY in your environment, or ensure the Retrivora Control Plane (https://www.retrivora.com) is reachable for proxy-based vector operations."
|
|
375
|
+
);
|
|
348
376
|
return;
|
|
349
377
|
}
|
|
350
378
|
this.client = new import_pinecone.Pinecone({ apiKey: key });
|
|
@@ -2385,6 +2413,10 @@ var LicenseVerifier = class {
|
|
|
2385
2413
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
2386
2414
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2387
2415
|
const now = Date.now();
|
|
2416
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
2417
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
2418
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
2419
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
2388
2420
|
if (licenseKey) {
|
|
2389
2421
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
2390
2422
|
const cached = this.cache.get(cacheKey);
|
|
@@ -2570,14 +2602,15 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
2570
2602
|
// Cache verified license for 60 seconds
|
|
2571
2603
|
// Retrivora's Public Key used to verify the license key signature.
|
|
2572
2604
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
2605
|
+
// Rotate this key only when the signing private key is replaced.
|
|
2573
2606
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
+
|
|
2580
|
-
|
|
2607
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
2608
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
2609
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
2610
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
2611
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
2612
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
2613
|
+
gQIDAQAB
|
|
2581
2614
|
-----END PUBLIC KEY-----`;
|
|
2582
2615
|
|
|
2583
2616
|
// src/config/constants.ts
|
|
@@ -4821,7 +4854,7 @@ var ConfigValidator = class {
|
|
|
4821
4854
|
// package.json
|
|
4822
4855
|
var package_default = {
|
|
4823
4856
|
name: "@retrivora-ai/rag-engine",
|
|
4824
|
-
version: "2.3.
|
|
4857
|
+
version: "2.3.5",
|
|
4825
4858
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4826
4859
|
author: "Abhinav Alkuchi",
|
|
4827
4860
|
license: "UNLICENSED",
|
|
@@ -11051,7 +11084,7 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
|
|
|
11051
11084
|
function enforceLicense(req, config, bodyLicenseKey) {
|
|
11052
11085
|
const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
|
|
11053
11086
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
11054
|
-
const projectId = config.projectId || "
|
|
11087
|
+
const projectId = config.projectId || "";
|
|
11055
11088
|
try {
|
|
11056
11089
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
11057
11090
|
return { ok: true, payload };
|
|
@@ -11527,7 +11560,7 @@ function createLicenseHandler(configOrPlugin, options) {
|
|
|
11527
11560
|
const config = plugin.getConfig();
|
|
11528
11561
|
const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
|
|
11529
11562
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
11530
|
-
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "
|
|
11563
|
+
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
|
|
11531
11564
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
11532
11565
|
return import_server.NextResponse.json({
|
|
11533
11566
|
valid: true,
|
|
@@ -12001,8 +12034,17 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
12001
12034
|
}
|
|
12002
12035
|
return void 0;
|
|
12003
12036
|
};
|
|
12037
|
+
console.log("LicenseValidator.validate()", request);
|
|
12038
|
+
console.log("LicenseValidator.validate() - licenseKey", licenseKey);
|
|
12039
|
+
console.log("LicenseValidator.validate() - projectId", projectId);
|
|
12040
|
+
console.log("LicenseValidator.validate() - sdkVersion", sdkVersion);
|
|
12041
|
+
console.log("LicenseValidator.validate() - sdk", sdk);
|
|
12042
|
+
console.log("LicenseValidator.validate() - platform", platform);
|
|
12043
|
+
console.log("LicenseValidator.validate() - retrivoraApiBase", retrivoraApiBase);
|
|
12044
|
+
console.log("LicenseValidator.validate() - customHeaders", customHeaders);
|
|
12004
12045
|
const rawKey = licenseKey || getHeader("x-license-key") || ((_a3 = getHeader("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY : "") || "";
|
|
12005
12046
|
const effectiveLicenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
12047
|
+
console.log("LicenseValidator.validate() - effectiveLicenseKey", effectiveLicenseKey);
|
|
12006
12048
|
if (!effectiveLicenseKey) {
|
|
12007
12049
|
this.purgeCache(effectiveLicenseKey);
|
|
12008
12050
|
throw new LicenseValidationError("Missing RETRIVORA_LICENSE_KEY in request. Set NEXT_PUBLIC_RETRIVORA_LICENSE_KEY in your environment or pass licenseKey as a prop.");
|
|
@@ -12038,7 +12080,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
12038
12080
|
});
|
|
12039
12081
|
} catch (err) {
|
|
12040
12082
|
try {
|
|
12041
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
12083
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
12042
12084
|
const fallbackResp = {
|
|
12043
12085
|
valid: true,
|
|
12044
12086
|
licenseStatus: "ACTIVE",
|
|
@@ -12057,7 +12099,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
12057
12099
|
}
|
|
12058
12100
|
if (res && !res.ok) {
|
|
12059
12101
|
try {
|
|
12060
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
12102
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
12061
12103
|
const fallbackResp = {
|
|
12062
12104
|
valid: true,
|
|
12063
12105
|
licenseStatus: "ACTIVE",
|
package/dist/server.mjs
CHANGED
|
@@ -140,14 +140,26 @@ var init_BaseVectorProvider = __esm({
|
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
// src/core/ConfigFetcher.ts
|
|
143
|
-
var ConfigFetcher;
|
|
143
|
+
var CONTROL_PLANE_URL, LLM_PROXY_BASE_URL, ConfigFetcher;
|
|
144
144
|
var init_ConfigFetcher = __esm({
|
|
145
145
|
"src/core/ConfigFetcher.ts"() {
|
|
146
146
|
"use strict";
|
|
147
|
+
CONTROL_PLANE_URL = "https://www.retrivora.com";
|
|
148
|
+
LLM_PROXY_BASE_URL = "https://www.retrivora.com/api/v1";
|
|
147
149
|
ConfigFetcher = class {
|
|
148
150
|
// 5-minute in-memory session cache
|
|
149
151
|
/**
|
|
150
|
-
* Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
|
|
152
|
+
* Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
|
|
153
|
+
*
|
|
154
|
+
* The SDK calls https://www.retrivora.com/api/v1/config with the project ID and license key.
|
|
155
|
+
* The server validates the license against the database and returns:
|
|
156
|
+
* - validity (tier, isActive, expiresAt)
|
|
157
|
+
* - LLM model info
|
|
158
|
+
* - embedding model info
|
|
159
|
+
* - Pinecone index name and workspace/namespace
|
|
160
|
+
*
|
|
161
|
+
* The Pinecone API key is NOT returned (server-only). The SDK uses local
|
|
162
|
+
* PINECONE_API_KEY if available, or vector operations are handled server-side.
|
|
151
163
|
*/
|
|
152
164
|
static async fetchRemoteConfig(projectId, licenseKey) {
|
|
153
165
|
var _a3, _b, _c, _d, _e, _f, _g2, _h, _i, _j, _k;
|
|
@@ -160,14 +172,11 @@ var init_ConfigFetcher = __esm({
|
|
|
160
172
|
const controlPlaneUrls = [
|
|
161
173
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
162
174
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"http://localhost:3000",
|
|
166
|
-
"http://localhost:3001"
|
|
167
|
-
].filter(Boolean);
|
|
175
|
+
CONTROL_PLANE_URL
|
|
176
|
+
].filter((url) => Boolean(url) && !url.includes("localhost") && !url.includes("127.0.0.1")).map((url) => url.replace(/\/$/, ""));
|
|
168
177
|
for (const baseUrl of controlPlaneUrls) {
|
|
169
178
|
try {
|
|
170
|
-
const url = `${baseUrl
|
|
179
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ""}`;
|
|
171
180
|
const res = await fetch(url, {
|
|
172
181
|
method: "GET",
|
|
173
182
|
headers: __spreadValues({
|
|
@@ -176,29 +185,41 @@ var init_ConfigFetcher = __esm({
|
|
|
176
185
|
});
|
|
177
186
|
if (res.ok) {
|
|
178
187
|
const data = await res.json();
|
|
179
|
-
if ((data == null ? void 0 : data.success) && (
|
|
188
|
+
if ((data == null ? void 0 : data.success) && (data == null ? void 0 : data.vectorDb)) {
|
|
180
189
|
const fetchedProjectId = data.projectId || projectId;
|
|
181
190
|
const config = {
|
|
182
191
|
projectId: fetchedProjectId,
|
|
192
|
+
tier: data.tier,
|
|
193
|
+
isActive: data.isActive,
|
|
194
|
+
expiresAt: data.expiresAt,
|
|
183
195
|
vectorDb: {
|
|
184
|
-
apiKey
|
|
196
|
+
// apiKey is not returned by the config API — it's a server-only secret.
|
|
197
|
+
// The SDK uses local PINECONE_API_KEY if available.
|
|
198
|
+
apiKey: data.vectorDb.apiKey || "",
|
|
185
199
|
indexName: data.vectorDb.indexName || "retrivora-free",
|
|
186
200
|
provider: data.vectorDb.provider || "pinecone",
|
|
187
|
-
projectId: fetchedProjectId
|
|
201
|
+
projectId: fetchedProjectId,
|
|
202
|
+
namespace: ((_a3 = data.workspace) == null ? void 0 : _a3.namespace) || data.vectorDb.namespace || fetchedProjectId
|
|
188
203
|
},
|
|
189
204
|
embedding: {
|
|
190
205
|
provider: ((_b = data.embedding) == null ? void 0 : _b.provider) || "universal_rest",
|
|
191
206
|
model: ((_c = data.embedding) == null ? void 0 : _c.model) || "text-embedding-004",
|
|
192
|
-
|
|
207
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
208
|
+
baseUrl: ((_d = data.embedding) == null ? void 0 : _d.baseUrl) || LLM_PROXY_BASE_URL,
|
|
193
209
|
apiKey: ((_e = data.embedding) == null ? void 0 : _e.apiKey) || licenseKey || "",
|
|
194
210
|
profile: ((_f = data.embedding) == null ? void 0 : _f.profile) || "litellm"
|
|
195
211
|
},
|
|
196
212
|
llm: {
|
|
197
213
|
provider: ((_g2 = data.llm) == null ? void 0 : _g2.provider) || "universal_rest",
|
|
198
214
|
model: ((_h = data.llm) == null ? void 0 : _h.model) || "llama-3.1-8b-instant",
|
|
199
|
-
|
|
215
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
216
|
+
baseUrl: ((_i = data.llm) == null ? void 0 : _i.baseUrl) || LLM_PROXY_BASE_URL,
|
|
200
217
|
apiKey: ((_j = data.llm) == null ? void 0 : _j.apiKey) || licenseKey || "",
|
|
201
218
|
profile: ((_k = data.llm) == null ? void 0 : _k.profile) || "litellm"
|
|
219
|
+
},
|
|
220
|
+
workspace: data.workspace || {
|
|
221
|
+
namespace: fetchedProjectId,
|
|
222
|
+
indexName: data.vectorDb.indexName || "retrivora-free"
|
|
202
223
|
}
|
|
203
224
|
};
|
|
204
225
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
@@ -317,19 +338,26 @@ var init_PineconeProvider = __esm({
|
|
|
317
338
|
})();
|
|
318
339
|
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || "default";
|
|
319
340
|
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
320
|
-
if (remoteConfig
|
|
321
|
-
|
|
322
|
-
|
|
341
|
+
if (remoteConfig) {
|
|
342
|
+
if (remoteConfig.apiKey) {
|
|
343
|
+
key = remoteConfig.apiKey;
|
|
344
|
+
this.apiKey = key;
|
|
345
|
+
}
|
|
323
346
|
if (remoteConfig.indexName) {
|
|
324
347
|
this.indexName = remoteConfig.indexName;
|
|
325
348
|
}
|
|
326
349
|
if (remoteConfig.projectId) {
|
|
327
350
|
this.projectId = remoteConfig.projectId;
|
|
328
351
|
}
|
|
352
|
+
if (remoteConfig.namespace) {
|
|
353
|
+
this.namespace = remoteConfig.namespace;
|
|
354
|
+
}
|
|
329
355
|
}
|
|
330
356
|
}
|
|
331
357
|
if (!key) {
|
|
332
|
-
console.warn(
|
|
358
|
+
console.warn(
|
|
359
|
+
"[PineconeProvider] Warning: No Pinecone API key available. Set PINECONE_API_KEY in your environment, or ensure the Retrivora Control Plane (https://www.retrivora.com) is reachable for proxy-based vector operations."
|
|
360
|
+
);
|
|
333
361
|
return;
|
|
334
362
|
}
|
|
335
363
|
this.client = new Pinecone({ apiKey: key });
|
|
@@ -2285,6 +2313,10 @@ var LicenseVerifier = class {
|
|
|
2285
2313
|
static verify(licenseKey, currentProjectId, provider, publicKeyOverride) {
|
|
2286
2314
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2287
2315
|
const now = Date.now();
|
|
2316
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
2317
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
2318
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
2319
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
2288
2320
|
if (licenseKey) {
|
|
2289
2321
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ""}:${publicKeyOverride || ""}`;
|
|
2290
2322
|
const cached = this.cache.get(cacheKey);
|
|
@@ -2470,14 +2502,15 @@ LicenseVerifier.CACHE_TTL_MS = 60 * 1e3;
|
|
|
2470
2502
|
// Cache verified license for 60 seconds
|
|
2471
2503
|
// Retrivora's Public Key used to verify the license key signature.
|
|
2472
2504
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
2505
|
+
// Rotate this key only when the signing private key is replaced.
|
|
2473
2506
|
LicenseVerifier.PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
+
|
|
2480
|
-
|
|
2507
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
2508
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
2509
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
2510
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
2511
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
2512
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
2513
|
+
gQIDAQAB
|
|
2481
2514
|
-----END PUBLIC KEY-----`;
|
|
2482
2515
|
|
|
2483
2516
|
// src/config/constants.ts
|
|
@@ -4721,7 +4754,7 @@ var ConfigValidator = class {
|
|
|
4721
4754
|
// package.json
|
|
4722
4755
|
var package_default = {
|
|
4723
4756
|
name: "@retrivora-ai/rag-engine",
|
|
4724
|
-
version: "2.3.
|
|
4757
|
+
version: "2.3.5",
|
|
4725
4758
|
description: "Retrivora AI is a plug-and-play AI engine for RAG chat experiences \u2014 generic vector DB + LLM provider, embeddable or standalone.",
|
|
4726
4759
|
author: "Abhinav Alkuchi",
|
|
4727
4760
|
license: "UNLICENSED",
|
|
@@ -10951,7 +10984,7 @@ function resolveLicenseKey(req, config, bodyLicenseKey) {
|
|
|
10951
10984
|
function enforceLicense(req, config, bodyLicenseKey) {
|
|
10952
10985
|
const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
|
|
10953
10986
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
10954
|
-
const projectId = config.projectId || "
|
|
10987
|
+
const projectId = config.projectId || "";
|
|
10955
10988
|
try {
|
|
10956
10989
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
10957
10990
|
return { ok: true, payload };
|
|
@@ -11427,7 +11460,7 @@ function createLicenseHandler(configOrPlugin, options) {
|
|
|
11427
11460
|
const config = plugin.getConfig();
|
|
11428
11461
|
const rawKey = req.headers.get("x-license-key") || (body == null ? void 0 : body.licenseKey) || ((_a3 = req.headers.get("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || config.licenseKey || process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY || "";
|
|
11429
11462
|
const licenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
11430
|
-
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "
|
|
11463
|
+
const projectId = (body == null ? void 0 : body.projectId) || config.projectId || "";
|
|
11431
11464
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
11432
11465
|
return NextResponse.json({
|
|
11433
11466
|
valid: true,
|
|
@@ -11901,8 +11934,17 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
11901
11934
|
}
|
|
11902
11935
|
return void 0;
|
|
11903
11936
|
};
|
|
11937
|
+
console.log("LicenseValidator.validate()", request);
|
|
11938
|
+
console.log("LicenseValidator.validate() - licenseKey", licenseKey);
|
|
11939
|
+
console.log("LicenseValidator.validate() - projectId", projectId);
|
|
11940
|
+
console.log("LicenseValidator.validate() - sdkVersion", sdkVersion);
|
|
11941
|
+
console.log("LicenseValidator.validate() - sdk", sdk);
|
|
11942
|
+
console.log("LicenseValidator.validate() - platform", platform);
|
|
11943
|
+
console.log("LicenseValidator.validate() - retrivoraApiBase", retrivoraApiBase);
|
|
11944
|
+
console.log("LicenseValidator.validate() - customHeaders", customHeaders);
|
|
11904
11945
|
const rawKey = licenseKey || getHeader("x-license-key") || ((_a3 = getHeader("authorization")) == null ? void 0 : _a3.replace(/^Bearer\s+/i, "")) || (typeof process !== "undefined" ? process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY : "") || "";
|
|
11905
11946
|
const effectiveLicenseKey = (rawKey || "").trim().replace(/^["']|["']$/g, "").trim();
|
|
11947
|
+
console.log("LicenseValidator.validate() - effectiveLicenseKey", effectiveLicenseKey);
|
|
11906
11948
|
if (!effectiveLicenseKey) {
|
|
11907
11949
|
this.purgeCache(effectiveLicenseKey);
|
|
11908
11950
|
throw new LicenseValidationError("Missing RETRIVORA_LICENSE_KEY in request. Set NEXT_PUBLIC_RETRIVORA_LICENSE_KEY in your environment or pass licenseKey as a prop.");
|
|
@@ -11938,7 +11980,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
11938
11980
|
});
|
|
11939
11981
|
} catch (err) {
|
|
11940
11982
|
try {
|
|
11941
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
11983
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
11942
11984
|
const fallbackResp = {
|
|
11943
11985
|
valid: true,
|
|
11944
11986
|
licenseStatus: "ACTIVE",
|
|
@@ -11957,7 +11999,7 @@ var _LicenseValidator = class _LicenseValidator {
|
|
|
11957
11999
|
}
|
|
11958
12000
|
if (res && !res.ok) {
|
|
11959
12001
|
try {
|
|
11960
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "
|
|
12002
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || "");
|
|
11961
12003
|
const fallbackResp = {
|
|
11962
12004
|
valid: true,
|
|
11963
12005
|
licenseStatus: "ACTIVE",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
|
|
5
5
|
"author": "Abhinav Alkuchi",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -136,4 +136,4 @@
|
|
|
136
136
|
"tsup": "^8.5.1",
|
|
137
137
|
"typescript": "^5"
|
|
138
138
|
}
|
|
139
|
-
}
|
|
139
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ConfigFetcher.ts — Dynamically fetches project credentials from Retrivora Control Plane
|
|
3
3
|
* without hardcoding plain-text master keys in NPM package binaries.
|
|
4
|
+
*
|
|
5
|
+
* SECURITY: The SDK must ONLY call the Retrivora Control Plane at https://www.retrivora.com.
|
|
6
|
+
* It must never call the end user's own localhost or any other endpoint.
|
|
7
|
+
* LLM and embedding calls are proxied through https://www.retrivora.com/api/v1 which
|
|
8
|
+
* forwards to https://llm.retrivora.com with the server-side LITELLM_MASTER_KEY.
|
|
4
9
|
*/
|
|
5
10
|
|
|
6
11
|
export interface RemoteVectorConfig {
|
|
@@ -8,6 +13,7 @@ export interface RemoteVectorConfig {
|
|
|
8
13
|
indexName: string;
|
|
9
14
|
provider: string;
|
|
10
15
|
projectId?: string;
|
|
16
|
+
namespace?: string;
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
export interface RemoteEmbeddingConfig {
|
|
@@ -28,20 +34,51 @@ export interface RemoteLLMConfig {
|
|
|
28
34
|
|
|
29
35
|
export interface RemoteConfig {
|
|
30
36
|
projectId?: string;
|
|
37
|
+
tier?: string;
|
|
38
|
+
isActive?: boolean;
|
|
39
|
+
expiresAt?: string;
|
|
31
40
|
vectorDb: RemoteVectorConfig;
|
|
32
41
|
embedding: RemoteEmbeddingConfig;
|
|
33
42
|
llm: RemoteLLMConfig;
|
|
43
|
+
workspace?: {
|
|
44
|
+
namespace: string;
|
|
45
|
+
indexName: string;
|
|
46
|
+
};
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
// Legacy alias
|
|
37
50
|
export type { RemoteVectorConfig as RemoteConfig_ };
|
|
38
51
|
|
|
52
|
+
/**
|
|
53
|
+
* The single source of truth for the Retrivora Control Plane URL.
|
|
54
|
+
* The SDK must only communicate with this endpoint — never with the end user's localhost.
|
|
55
|
+
*/
|
|
56
|
+
const CONTROL_PLANE_URL = 'https://www.retrivora.com';
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The LLM/Embedding proxy gateway. All LLM and embedding requests are routed
|
|
60
|
+
* through https://www.retrivora.com/api/v1, which validates the license key and
|
|
61
|
+
* forwards to https://llm.retrivora.com with the server-side master key.
|
|
62
|
+
* End users never need to know about llm.retrivora.com directly.
|
|
63
|
+
*/
|
|
64
|
+
const LLM_PROXY_BASE_URL = 'https://www.retrivora.com/api/v1';
|
|
65
|
+
|
|
39
66
|
export class ConfigFetcher {
|
|
40
67
|
private static cache = new Map<string, { config: RemoteConfig; cachedAt: number }>();
|
|
41
68
|
private static readonly TTL_MS = 5 * 60 * 1000; // 5-minute in-memory session cache
|
|
42
69
|
|
|
43
70
|
/**
|
|
44
|
-
* Fetch full project configuration (vectorDb + embedding + llm) from Retrivora Control Plane.
|
|
71
|
+
* Fetch full project configuration (vectorDb + embedding + llm + workspace) from Retrivora Control Plane.
|
|
72
|
+
*
|
|
73
|
+
* The SDK calls https://www.retrivora.com/api/v1/config with the project ID and license key.
|
|
74
|
+
* The server validates the license against the database and returns:
|
|
75
|
+
* - validity (tier, isActive, expiresAt)
|
|
76
|
+
* - LLM model info
|
|
77
|
+
* - embedding model info
|
|
78
|
+
* - Pinecone index name and workspace/namespace
|
|
79
|
+
*
|
|
80
|
+
* The Pinecone API key is NOT returned (server-only). The SDK uses local
|
|
81
|
+
* PINECONE_API_KEY if available, or vector operations are handled server-side.
|
|
45
82
|
*/
|
|
46
83
|
static async fetchRemoteConfig(projectId: string, licenseKey?: string): Promise<RemoteConfig | null> {
|
|
47
84
|
const cacheKey = `${projectId}:${licenseKey || ''}`;
|
|
@@ -52,18 +89,20 @@ export class ConfigFetcher {
|
|
|
52
89
|
return cached.config;
|
|
53
90
|
}
|
|
54
91
|
|
|
92
|
+
// SECURITY: Only call the Retrivora Control Plane — never localhost or any other endpoint.
|
|
93
|
+
// Environment overrides are allowed for explicit server-side configuration, but
|
|
94
|
+
// localhost URLs are explicitly excluded to prevent calling the end user's own app.
|
|
55
95
|
const controlPlaneUrls = [
|
|
56
96
|
process.env.RETRIVORA_CONTROL_PLANE_URL,
|
|
57
97
|
process.env.NEXT_PUBLIC_RETRIVORA_CONTROL_PLANE_URL,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
].filter(Boolean) as string[];
|
|
98
|
+
CONTROL_PLANE_URL,
|
|
99
|
+
]
|
|
100
|
+
.filter((url): url is string => Boolean(url) && !url!.includes('localhost') && !url!.includes('127.0.0.1'))
|
|
101
|
+
.map((url) => url.replace(/\/$/, ''));
|
|
63
102
|
|
|
64
103
|
for (const baseUrl of controlPlaneUrls) {
|
|
65
104
|
try {
|
|
66
|
-
const url = `${baseUrl
|
|
105
|
+
const url = `${baseUrl}/api/v1/config?projectId=${encodeURIComponent(projectId)}${licenseKey ? `&licenseKey=${encodeURIComponent(licenseKey)}` : ''}`;
|
|
67
106
|
const res = await fetch(url, {
|
|
68
107
|
method: 'GET',
|
|
69
108
|
headers: {
|
|
@@ -74,30 +113,44 @@ export class ConfigFetcher {
|
|
|
74
113
|
|
|
75
114
|
if (res.ok) {
|
|
76
115
|
const data = await res.json();
|
|
77
|
-
|
|
116
|
+
// NOTE: The config API intentionally does NOT return vectorDb.apiKey (server-only secret).
|
|
117
|
+
// We check for data.success and data.vectorDb presence instead.
|
|
118
|
+
if (data?.success && data?.vectorDb) {
|
|
78
119
|
const fetchedProjectId = data.projectId || projectId;
|
|
79
120
|
const config: RemoteConfig = {
|
|
80
121
|
projectId: fetchedProjectId,
|
|
122
|
+
tier: data.tier,
|
|
123
|
+
isActive: data.isActive,
|
|
124
|
+
expiresAt: data.expiresAt,
|
|
81
125
|
vectorDb: {
|
|
82
|
-
apiKey
|
|
126
|
+
// apiKey is not returned by the config API — it's a server-only secret.
|
|
127
|
+
// The SDK uses local PINECONE_API_KEY if available.
|
|
128
|
+
apiKey: data.vectorDb.apiKey || '',
|
|
83
129
|
indexName: data.vectorDb.indexName || 'retrivora-free',
|
|
84
130
|
provider: data.vectorDb.provider || 'pinecone',
|
|
85
131
|
projectId: fetchedProjectId,
|
|
132
|
+
namespace: data.workspace?.namespace || data.vectorDb.namespace || fetchedProjectId,
|
|
86
133
|
},
|
|
87
134
|
embedding: {
|
|
88
135
|
provider: data.embedding?.provider || 'universal_rest',
|
|
89
136
|
model: data.embedding?.model || 'text-embedding-004',
|
|
90
|
-
|
|
137
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
138
|
+
baseUrl: data.embedding?.baseUrl || LLM_PROXY_BASE_URL,
|
|
91
139
|
apiKey: data.embedding?.apiKey || licenseKey || '',
|
|
92
140
|
profile: data.embedding?.profile || 'litellm',
|
|
93
141
|
},
|
|
94
142
|
llm: {
|
|
95
143
|
provider: data.llm?.provider || 'universal_rest',
|
|
96
144
|
model: data.llm?.model || 'llama-3.1-8b-instant',
|
|
97
|
-
|
|
145
|
+
// Route through www.retrivora.com proxy, not llm.retrivora.com directly.
|
|
146
|
+
baseUrl: data.llm?.baseUrl || LLM_PROXY_BASE_URL,
|
|
98
147
|
apiKey: data.llm?.apiKey || licenseKey || '',
|
|
99
148
|
profile: data.llm?.profile || 'litellm',
|
|
100
149
|
},
|
|
150
|
+
workspace: data.workspace || {
|
|
151
|
+
namespace: fetchedProjectId,
|
|
152
|
+
indexName: data.vectorDb.indexName || 'retrivora-free',
|
|
153
|
+
},
|
|
101
154
|
};
|
|
102
155
|
this.cache.set(cacheKey, { config, cachedAt: now });
|
|
103
156
|
return config;
|
|
@@ -139,16 +139,25 @@ export class LicenseValidator {
|
|
|
139
139
|
return undefined;
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
+
console.log('LicenseValidator.validate()', request);
|
|
143
|
+
console.log('LicenseValidator.validate() - licenseKey', licenseKey);
|
|
144
|
+
console.log('LicenseValidator.validate() - projectId', projectId);
|
|
145
|
+
console.log('LicenseValidator.validate() - sdkVersion', sdkVersion);
|
|
146
|
+
console.log('LicenseValidator.validate() - sdk', sdk);
|
|
147
|
+
console.log('LicenseValidator.validate() - platform', platform);
|
|
148
|
+
console.log('LicenseValidator.validate() - retrivoraApiBase', retrivoraApiBase);
|
|
149
|
+
console.log('LicenseValidator.validate() - customHeaders', customHeaders);
|
|
142
150
|
const rawKey =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
151
|
+
licenseKey ||
|
|
152
|
+
getHeader('x-license-key') ||
|
|
153
|
+
getHeader('authorization')?.replace(/^Bearer\s+/i, '') ||
|
|
154
|
+
(typeof process !== 'undefined'
|
|
155
|
+
? (process.env.NEXT_PUBLIC_RETRIVORA_LICENSE_KEY || process.env.RETRIVORA_LICENSE_KEY)
|
|
156
|
+
: '') ||
|
|
149
157
|
'';
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
|
|
159
|
+
const effectiveLicenseKey = (rawKey || '').trim().replace(/^["']|["']$/g, '').trim();
|
|
160
|
+
console.log('LicenseValidator.validate() - effectiveLicenseKey', effectiveLicenseKey);
|
|
152
161
|
|
|
153
162
|
if (!effectiveLicenseKey) {
|
|
154
163
|
this.purgeCache(effectiveLicenseKey);
|
|
@@ -192,7 +201,7 @@ export class LicenseValidator {
|
|
|
192
201
|
} catch (err: any) {
|
|
193
202
|
// Fallback: If network error occurs, verify locally via RSA LicenseVerifier
|
|
194
203
|
try {
|
|
195
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || '
|
|
204
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || '');
|
|
196
205
|
const fallbackResp: LicenseValidationResponse = {
|
|
197
206
|
valid: true,
|
|
198
207
|
licenseStatus: 'ACTIVE',
|
|
@@ -213,7 +222,7 @@ export class LicenseValidator {
|
|
|
213
222
|
if (res && !res.ok) {
|
|
214
223
|
// Attempt local verification fallback if API route returned 404 or non-OK response
|
|
215
224
|
try {
|
|
216
|
-
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || '
|
|
225
|
+
const payload = LicenseVerifier.verify(effectiveLicenseKey, projectId || '');
|
|
217
226
|
const fallbackResp: LicenseValidationResponse = {
|
|
218
227
|
valid: true,
|
|
219
228
|
licenseStatus: 'ACTIVE',
|
|
@@ -49,14 +49,15 @@ export class LicenseVerifier {
|
|
|
49
49
|
|
|
50
50
|
// Retrivora's Public Key used to verify the license key signature.
|
|
51
51
|
// In production, this matches the private key held by Retrivora SaaS.
|
|
52
|
+
// Rotate this key only when the signing private key is replaced.
|
|
52
53
|
private static readonly PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
+
|
|
59
|
-
|
|
54
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoOQlmDSKfCZaRy06rxwa
|
|
55
|
+
chuDimlF134xTCitKDTPTPizF23oSn34pGDJakm/0T09JVUX8L/cvhGPe/3lf/g9
|
|
56
|
+
4Y1q+Gb2KVM17KNGeT1Aj9Ua3BKz/yao/oFhi/r3Zt3cWY13B/Rd6clqY9WshIAV
|
|
57
|
+
NqZNM8ilTl777cMbyym+6D+mzGXgmnJAO5brddIAI9FPLW0T3Znt8vEqDOIljEkC
|
|
58
|
+
HCGHeirKABLbjKSJ4hljCa3vVitWqndhiq8CBSJG6HatiSGYotgMWGRY+0EbdlEv
|
|
59
|
+
OJP4SqafQ3aD6YnL9q1n15QKwxu/uMK+JGM2VxxuyUi9GANtMIkCYy9xya73P4Qc
|
|
60
|
+
gQIDAQAB
|
|
60
61
|
-----END PUBLIC KEY-----`;
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -75,6 +76,10 @@ MwIDAQAB
|
|
|
75
76
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
76
77
|
const now = Date.now();
|
|
77
78
|
|
|
79
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - licenseKey`, licenseKey);
|
|
80
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - currentProjectId`, currentProjectId);
|
|
81
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - provider`, provider);
|
|
82
|
+
console.log(`[Retrivora SDK] LicenseVerifier.verify() - publicKeyOverride`, publicKeyOverride);
|
|
78
83
|
// Check verification cache to bypass crypto computations on hot paths
|
|
79
84
|
if (licenseKey) {
|
|
80
85
|
const cacheKey = `${licenseKey}:${currentProjectId}:${provider || ''}:${publicKeyOverride || ''}`;
|
package/src/handlers/index.ts
CHANGED
|
@@ -213,7 +213,7 @@ function enforceLicense(
|
|
|
213
213
|
): { ok: true; payload: LicensePayload } | { ok: false; response: Response } {
|
|
214
214
|
const rawKey = resolveLicenseKey(req, config, bodyLicenseKey);
|
|
215
215
|
const licenseKey = (rawKey || '').trim().replace(/^["']|["']$/g, '').trim();
|
|
216
|
-
const projectId = config.projectId || '
|
|
216
|
+
const projectId = config.projectId || '';
|
|
217
217
|
|
|
218
218
|
try {
|
|
219
219
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
@@ -935,7 +935,7 @@ export function createLicenseHandler(
|
|
|
935
935
|
|
|
936
936
|
const licenseKey = (rawKey || '').trim().replace(/^["']|["']$/g, '').trim();
|
|
937
937
|
|
|
938
|
-
const projectId = body?.projectId || config.projectId || '
|
|
938
|
+
const projectId = body?.projectId || config.projectId || '';
|
|
939
939
|
|
|
940
940
|
const payload = LicenseVerifier.verify(licenseKey, projectId);
|
|
941
941
|
|
|
@@ -104,20 +104,33 @@ export class PineconeProvider extends BaseVectorProvider {
|
|
|
104
104
|
const projectId = process.env.RAG_PROJECT_ID || process.env.NEXT_PUBLIC_RAG_PROJECT_ID || jwtProjectId || this.projectId || 'default';
|
|
105
105
|
|
|
106
106
|
const remoteConfig = await ConfigFetcher.fetchRemoteVectorConfig(projectId, licenseKey);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
|
|
108
|
+
// The config API does NOT return the Pinecone API key (server-only secret).
|
|
109
|
+
// We still use the remote config for indexName and namespace/workspace info.
|
|
110
|
+
if (remoteConfig) {
|
|
111
|
+
if (remoteConfig.apiKey) {
|
|
112
|
+
key = remoteConfig.apiKey;
|
|
113
|
+
this.apiKey = key;
|
|
114
|
+
}
|
|
110
115
|
if (remoteConfig.indexName) {
|
|
111
116
|
this.indexName = remoteConfig.indexName;
|
|
112
117
|
}
|
|
113
118
|
if (remoteConfig.projectId) {
|
|
114
119
|
this.projectId = remoteConfig.projectId;
|
|
115
120
|
}
|
|
121
|
+
if (remoteConfig.namespace) {
|
|
122
|
+
// Store namespace for use in queries — ensures workspace isolation
|
|
123
|
+
(this as any).namespace = remoteConfig.namespace;
|
|
124
|
+
}
|
|
116
125
|
}
|
|
117
126
|
}
|
|
118
127
|
|
|
119
128
|
if (!key) {
|
|
120
|
-
console.warn(
|
|
129
|
+
console.warn(
|
|
130
|
+
'[PineconeProvider] Warning: No Pinecone API key available. ' +
|
|
131
|
+
'Set PINECONE_API_KEY in your environment, or ensure the Retrivora Control Plane ' +
|
|
132
|
+
'(https://www.retrivora.com) is reachable for proxy-based vector operations.'
|
|
133
|
+
);
|
|
121
134
|
return;
|
|
122
135
|
}
|
|
123
136
|
|