mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
librechat-data-provider → @hanzochat/data-provider @librechat/data-schemas → @hanzochat/data-schemas @librechat/client → @hanzochat/client (@hanzochat/api already forked; external @librechat/agents fork follows) All imports, package.json names/deps, tsconfig path aliases, jest moduleNameMapper, and rollup/vite build aliases updated. The data-provider react-query subpath resolves via the exports map. Lockfiles regenerated in a follow-on once the canonical package manager is confirmed.
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
const { PermissionTypes, Permissions } = require('@hanzochat/data-provider');
|
|
const {
|
|
generateCheckAccess,
|
|
preAuthTenantMiddleware,
|
|
createRequireApiKeyAuth,
|
|
createRemoteAgentAuth,
|
|
createCheckRemoteAgentAccess,
|
|
} = require('@hanzochat/api');
|
|
const { getEffectivePermissions } = require('~/server/services/PermissionService');
|
|
const { getAppConfig } = require('~/server/services/Config');
|
|
const db = require('~/models');
|
|
|
|
const apiKeyMiddleware = createRequireApiKeyAuth({
|
|
validateAgentApiKey: db.validateAgentApiKey,
|
|
findUser: db.findUser,
|
|
});
|
|
|
|
const requireRemoteAgentAuth = createRemoteAgentAuth({
|
|
apiKeyMiddleware,
|
|
findUser: db.findUser,
|
|
updateUser: db.updateUser,
|
|
getAppConfig,
|
|
});
|
|
|
|
const checkRemoteAgentsFeature = generateCheckAccess({
|
|
permissionType: PermissionTypes.REMOTE_AGENTS,
|
|
permissions: [Permissions.USE],
|
|
getRoleByName: db.getRoleByName,
|
|
});
|
|
|
|
const checkAgentPermission = createCheckRemoteAgentAccess({
|
|
getAgent: db.getAgent,
|
|
getEffectivePermissions,
|
|
});
|
|
|
|
module.exports = {
|
|
checkAgentPermission,
|
|
preAuthTenantMiddleware,
|
|
requireRemoteAgentAuth,
|
|
checkRemoteAgentsFeature,
|
|
};
|