mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 05:52:10 +00:00
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
* fix: Write User Provider Keys With Random-IV v3 Format * fix: Reject Undelimited Input in decryptV2 Instead of Returning It * fix: Default 2FA Backup Codes to the Strong Format * fix: Limit Admin Secret Preview to the Last Four Characters * fix: Re-Derive Stored Secret Previews Under the Last-Four Policy * test: Build Legacy Credential Fixtures With the Server Key * fix: Load Request Config for User Key Writes and Mask Legacy Previews
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
const express = require('express');
|
|
const { updateUserKey, deleteUserKey, getUserKeyExpiry } = require('~/models');
|
|
const { configMiddleware, requireJwtAuth } = require('~/server/middleware');
|
|
|
|
const router = express.Router();
|
|
|
|
router.put('/', requireJwtAuth, configMiddleware, async (req, res) => {
|
|
if (req.body == null || typeof req.body !== 'object') {
|
|
return res.status(400).send({ error: 'Invalid request body.' });
|
|
}
|
|
const { name, value, expiresAt } = req.body;
|
|
await updateUserKey({
|
|
userId: req.user.id,
|
|
name,
|
|
value,
|
|
expiresAt,
|
|
writeFormat: req.config?.credentials?.writeFormat,
|
|
});
|
|
res.status(201).send();
|
|
});
|
|
|
|
router.delete('/:name', requireJwtAuth, async (req, res) => {
|
|
const { name } = req.params;
|
|
await deleteUserKey({ userId: req.user.id, name });
|
|
res.status(204).send();
|
|
});
|
|
|
|
router.delete('/', requireJwtAuth, async (req, res) => {
|
|
const { all } = req.query;
|
|
|
|
if (all !== 'true') {
|
|
return res.status(400).send({ error: 'Specify either all=true to delete.' });
|
|
}
|
|
|
|
await deleteUserKey({ userId: req.user.id, all: true });
|
|
|
|
res.status(204).send();
|
|
});
|
|
|
|
router.get('/', requireJwtAuth, async (req, res) => {
|
|
const { name } = req.query;
|
|
const response = await getUserKeyExpiry({ userId: req.user.id, name });
|
|
res.status(200).send(response);
|
|
});
|
|
|
|
module.exports = router;
|