librechat-data-provider 0.8.302 → 0.8.401
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/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-query/index.es.js +1 -1
- package/dist/react-query/index.es.js.map +1 -1
- package/package.json +1 -1
- package/specs/mcp.spec.ts +147 -0
- package/specs/utils.spec.ts +71 -4
- package/src/accessPermissions.ts +4 -4
- package/src/config.ts +9 -1
- package/src/data-service.ts +8 -6
- package/src/file-config.spec.ts +41 -3
- package/src/file-config.ts +14 -6
- package/src/mcp.ts +32 -3
- package/src/roles.spec.ts +132 -0
- package/src/roles.ts +24 -4
- package/src/types.ts +18 -25
- package/src/utils.ts +30 -7
package/src/roles.ts
CHANGED
|
@@ -180,10 +180,20 @@ export const roleDefaults = defaultRolesSchema.parse({
|
|
|
180
180
|
[SystemRoles.USER]: {
|
|
181
181
|
name: SystemRoles.USER,
|
|
182
182
|
permissions: {
|
|
183
|
-
[PermissionTypes.PROMPTS]: {
|
|
183
|
+
[PermissionTypes.PROMPTS]: {
|
|
184
|
+
[Permissions.USE]: true,
|
|
185
|
+
[Permissions.CREATE]: true,
|
|
186
|
+
[Permissions.SHARE]: false,
|
|
187
|
+
[Permissions.SHARE_PUBLIC]: false,
|
|
188
|
+
},
|
|
184
189
|
[PermissionTypes.BOOKMARKS]: {},
|
|
185
190
|
[PermissionTypes.MEMORIES]: {},
|
|
186
|
-
[PermissionTypes.AGENTS]: {
|
|
191
|
+
[PermissionTypes.AGENTS]: {
|
|
192
|
+
[Permissions.USE]: true,
|
|
193
|
+
[Permissions.CREATE]: true,
|
|
194
|
+
[Permissions.SHARE]: false,
|
|
195
|
+
[Permissions.SHARE_PUBLIC]: false,
|
|
196
|
+
},
|
|
187
197
|
[PermissionTypes.MULTI_CONVO]: {},
|
|
188
198
|
[PermissionTypes.TEMPORARY_CHAT]: {},
|
|
189
199
|
[PermissionTypes.RUN_CODE]: {},
|
|
@@ -198,8 +208,18 @@ export const roleDefaults = defaultRolesSchema.parse({
|
|
|
198
208
|
},
|
|
199
209
|
[PermissionTypes.FILE_SEARCH]: {},
|
|
200
210
|
[PermissionTypes.FILE_CITATIONS]: {},
|
|
201
|
-
[PermissionTypes.MCP_SERVERS]: {
|
|
202
|
-
|
|
211
|
+
[PermissionTypes.MCP_SERVERS]: {
|
|
212
|
+
[Permissions.USE]: true,
|
|
213
|
+
[Permissions.CREATE]: false,
|
|
214
|
+
[Permissions.SHARE]: false,
|
|
215
|
+
[Permissions.SHARE_PUBLIC]: false,
|
|
216
|
+
},
|
|
217
|
+
[PermissionTypes.REMOTE_AGENTS]: {
|
|
218
|
+
[Permissions.USE]: false,
|
|
219
|
+
[Permissions.CREATE]: false,
|
|
220
|
+
[Permissions.SHARE]: false,
|
|
221
|
+
[Permissions.SHARE_PUBLIC]: false,
|
|
222
|
+
},
|
|
203
223
|
},
|
|
204
224
|
},
|
|
205
225
|
});
|
package/src/types.ts
CHANGED
|
@@ -425,28 +425,29 @@ export type TLoginResponse = {
|
|
|
425
425
|
tempToken?: string;
|
|
426
426
|
};
|
|
427
427
|
|
|
428
|
+
/** Shared payload for any operation that requires OTP or backup-code verification. */
|
|
429
|
+
export type TOTPVerificationPayload = {
|
|
430
|
+
token?: string;
|
|
431
|
+
backupCode?: string;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export type TEnable2FARequest = TOTPVerificationPayload;
|
|
435
|
+
|
|
428
436
|
export type TEnable2FAResponse = {
|
|
429
437
|
otpauthUrl: string;
|
|
430
438
|
backupCodes: string[];
|
|
431
439
|
message?: string;
|
|
432
440
|
};
|
|
433
441
|
|
|
434
|
-
export type TVerify2FARequest =
|
|
435
|
-
token?: string;
|
|
436
|
-
backupCode?: string;
|
|
437
|
-
};
|
|
442
|
+
export type TVerify2FARequest = TOTPVerificationPayload;
|
|
438
443
|
|
|
439
444
|
export type TVerify2FAResponse = {
|
|
440
445
|
message: string;
|
|
441
446
|
};
|
|
442
447
|
|
|
443
|
-
/**
|
|
444
|
-
|
|
445
|
-
*/
|
|
446
|
-
export type TVerify2FATempRequest = {
|
|
448
|
+
/** For verifying 2FA during login with a temporary token. */
|
|
449
|
+
export type TVerify2FATempRequest = TOTPVerificationPayload & {
|
|
447
450
|
tempToken: string;
|
|
448
|
-
token?: string;
|
|
449
|
-
backupCode?: string;
|
|
450
451
|
};
|
|
451
452
|
|
|
452
453
|
export type TVerify2FATempResponse = {
|
|
@@ -455,30 +456,22 @@ export type TVerify2FATempResponse = {
|
|
|
455
456
|
message?: string;
|
|
456
457
|
};
|
|
457
458
|
|
|
458
|
-
|
|
459
|
-
* Request for disabling 2FA.
|
|
460
|
-
*/
|
|
461
|
-
export type TDisable2FARequest = {
|
|
462
|
-
token?: string;
|
|
463
|
-
backupCode?: string;
|
|
464
|
-
};
|
|
459
|
+
export type TDisable2FARequest = TOTPVerificationPayload;
|
|
465
460
|
|
|
466
|
-
/**
|
|
467
|
-
* Response from disabling 2FA.
|
|
468
|
-
*/
|
|
469
461
|
export type TDisable2FAResponse = {
|
|
470
462
|
message: string;
|
|
471
463
|
};
|
|
472
464
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
*/
|
|
465
|
+
export type TRegenerateBackupCodesRequest = TOTPVerificationPayload;
|
|
466
|
+
|
|
476
467
|
export type TRegenerateBackupCodesResponse = {
|
|
477
|
-
message
|
|
468
|
+
message?: string;
|
|
478
469
|
backupCodes: string[];
|
|
479
|
-
backupCodesHash:
|
|
470
|
+
backupCodesHash: TBackupCode[];
|
|
480
471
|
};
|
|
481
472
|
|
|
473
|
+
export type TDeleteUserRequest = TOTPVerificationPayload;
|
|
474
|
+
|
|
482
475
|
export type TRequestPasswordReset = {
|
|
483
476
|
email: string;
|
|
484
477
|
};
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
export const envVarRegex = /^\${(.+)}$/;
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Infrastructure env vars that must never be resolved via placeholder expansion.
|
|
5
|
+
* These are internal secrets whose exposure would compromise the system —
|
|
6
|
+
* they have no legitimate reason to appear in outbound headers, MCP env/args, or OAuth config.
|
|
7
|
+
*
|
|
8
|
+
* Intentionally excludes API keys (operators reference them in config) and
|
|
9
|
+
* OAuth/session secrets (referenced in MCP OAuth config via processMCPEnv).
|
|
10
|
+
*/
|
|
11
|
+
const SENSITIVE_ENV_VARS = new Set([
|
|
12
|
+
'JWT_SECRET',
|
|
13
|
+
'JWT_REFRESH_SECRET',
|
|
14
|
+
'CREDS_KEY',
|
|
15
|
+
'CREDS_IV',
|
|
16
|
+
'MEILI_MASTER_KEY',
|
|
17
|
+
'MONGO_URI',
|
|
18
|
+
'REDIS_URI',
|
|
19
|
+
'REDIS_PASSWORD',
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
/** Returns true when `varName` refers to an infrastructure secret that must not leak. */
|
|
23
|
+
export function isSensitiveEnvVar(varName: string): boolean {
|
|
24
|
+
return SENSITIVE_ENV_VARS.has(varName);
|
|
25
|
+
}
|
|
26
|
+
|
|
3
27
|
/** Extracts the environment variable name from a template literal string */
|
|
4
28
|
export function extractVariableName(value: string): string | null {
|
|
5
29
|
if (!value) {
|
|
@@ -16,21 +40,20 @@ export function extractEnvVariable(value: string) {
|
|
|
16
40
|
return value;
|
|
17
41
|
}
|
|
18
42
|
|
|
19
|
-
// Trim the input
|
|
20
43
|
const trimmed = value.trim();
|
|
21
44
|
|
|
22
|
-
// Special case: if it's just a single environment variable
|
|
23
45
|
const singleMatch = trimmed.match(envVarRegex);
|
|
24
46
|
if (singleMatch) {
|
|
25
47
|
const varName = singleMatch[1];
|
|
48
|
+
if (isSensitiveEnvVar(varName)) {
|
|
49
|
+
return trimmed;
|
|
50
|
+
}
|
|
26
51
|
return process.env[varName] || trimmed;
|
|
27
52
|
}
|
|
28
53
|
|
|
29
|
-
// For multiple variables, process them using a regex loop
|
|
30
54
|
const regex = /\${([^}]+)}/g;
|
|
31
55
|
let result = trimmed;
|
|
32
56
|
|
|
33
|
-
// First collect all matches and their positions
|
|
34
57
|
const matches = [];
|
|
35
58
|
let match;
|
|
36
59
|
while ((match = regex.exec(trimmed)) !== null) {
|
|
@@ -41,12 +64,12 @@ export function extractEnvVariable(value: string) {
|
|
|
41
64
|
});
|
|
42
65
|
}
|
|
43
66
|
|
|
44
|
-
// Process matches in reverse order to avoid position shifts
|
|
45
67
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
46
68
|
const { fullMatch, varName, index } = matches[i];
|
|
69
|
+
if (isSensitiveEnvVar(varName)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
47
72
|
const envValue = process.env[varName] || fullMatch;
|
|
48
|
-
|
|
49
|
-
// Replace at exact position
|
|
50
73
|
result = result.substring(0, index) + envValue + result.substring(index + fullMatch.length);
|
|
51
74
|
}
|
|
52
75
|
|