mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
* fix: Encrypt User Plugin Credentials With Random-IV v3 Format * test: Cover Credential Encryption Formats in Mock E2E Scenarios * test: Round-Trip Real Credential Helpers in PluginService Spec * 🙈 fix: Remove SharePoint Picker Payload Logging (#16997) * fix: Add credentials.writeFormat to Gate v3 Credential Writes During Rollouts * test: Expect 201 When the Legacy Write Format Override Is Created * 🔊 fix: Clear TTS Audio Cache On Session End and Hash Its Keys (#16998) * fix: Clear TTS Audio Cache On Session End and Hash Its Keys * fix: Read Manual TTS Replays From the Hashed Cache Key * fix: Purge Legacy TTS Cache Keys and Fence Writes Across Logout * fix: Keep TTS Cache Writes Off the Playback Path * test: Expect Hashed Keys in the StreamAudio Cache Lookup * test: Use a Single-Token Reply Label in the TTS Cache Scenario * fix: Settle TTS Cache Clear Before IdP Logout and Across Tabs * test: Cover the TTS Cache Fence When Another Tab Logs Out * test: Wait for the Second Tab Before Logging Out in the TTS Scenario * fix: Latch TTS Cache Writes Shut Until the Tab Authenticates Again * fix: Reopen TTS Cache Writes When Authentication Completes In Place * fix: Leave for the IdP Even When TTS Cache Cleanup Fails * fix: Retry a Failed Legacy TTS Purge and Fence Other Tabs on Manual Clear * fix: Rerun the Legacy TTS Purge After Each Clear and Sign-In * fix: Rerun the Legacy TTS Purge When Another Tab Clears * fix: Fence Pre-Auth TTS Writes, Retry Failed Clears, and Fall Back to Storage Events * fix: Version the Hashed TTS Cache Key Path * fix: Move TTS Audio to a New Cache and Keep It Closed Until a Failed Clear Succeeds * fix: Persist a Pending TTS Cache Delete Across Navigation * fix: Reopen TTS Caching Only on Session Start and Fence Cache Reads * fix: Keep the TTS Delete Fence in Cache Storage and Close Reads After Logout * refactor: Keep Read-Aloud Audio in Tab Memory Instead of Cache Storage * test: Return to the Conversation After Re-Login in the TTS Logout Scenario * test: Close the Phone Sidebar Before Replaying in the TTS Logout Scenario * fix: Bound the In-Memory TTS Cache by Size as Well as Count * fix: Scope Cached TTS Audio to the Signed-In User * fix: Keep the Settings Cache Delete Available While Legacy Audio Remains * fix: Recheck Legacy TTS Audio After a Settings Clear and on Unowned Handoff * fix: Fence TTS Writes Started Before an Account Signs In * test: Opt the Fresh TTS Account Into Enter-to-Send
87 lines
3.1 KiB
JavaScript
87 lines
3.1 KiB
JavaScript
const mockLoggerError = jest.fn();
|
|
const mockFindOnePluginAuth = jest.fn();
|
|
const mockUpdatePluginAuth = jest.fn();
|
|
|
|
jest.mock('@librechat/data-schemas', () => ({
|
|
...jest.requireActual('@librechat/data-schemas'),
|
|
logger: { error: mockLoggerError },
|
|
}));
|
|
|
|
jest.mock('@librechat/api', () => {
|
|
const { encryptCredential, decryptCredential } = jest.requireActual('@librechat/api');
|
|
return { encryptCredential, decryptCredential };
|
|
});
|
|
|
|
jest.mock('~/models', () => ({
|
|
findOnePluginAuth: (...args) => mockFindOnePluginAuth(...args),
|
|
updatePluginAuth: (...args) => mockUpdatePluginAuth(...args),
|
|
deletePluginAuth: jest.fn(),
|
|
}));
|
|
|
|
const { getUserPluginAuthValue, updateUserPluginAuth } = require('./PluginService');
|
|
|
|
describe('getUserPluginAuthValue', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('does not log an expected missing auth value', async () => {
|
|
mockFindOnePluginAuth.mockResolvedValue(null);
|
|
|
|
await expect(
|
|
getUserPluginAuthValue('user-id', 'WEB_SEARCH_SELECTED_PROVIDER'),
|
|
).rejects.toMatchObject({ code: 'PLUGIN_AUTH_NOT_FOUND' });
|
|
|
|
expect(mockLoggerError).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('still logs credential-store failures', async () => {
|
|
const error = new Error('database unavailable');
|
|
mockFindOnePluginAuth.mockRejectedValue(error);
|
|
|
|
await expect(getUserPluginAuthValue('user-id', 'WEB_SEARCH_SELECTED_PROVIDER')).rejects.toBe(
|
|
error,
|
|
);
|
|
|
|
expect(mockLoggerError).toHaveBeenCalledWith('[getUserPluginAuthValue]', error);
|
|
});
|
|
});
|
|
|
|
describe('plugin auth encryption', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('stores a random-IV v3 value that reads back as the plaintext', async () => {
|
|
mockUpdatePluginAuth.mockImplementation(async (doc) => doc);
|
|
|
|
await updateUserPluginAuth('user-id', 'API_KEY', 'plugin', 'plain');
|
|
await updateUserPluginAuth('user-id', 'API_KEY', 'plugin', 'plain');
|
|
|
|
const [first, second] = mockUpdatePluginAuth.mock.calls.map(([doc]) => doc.value);
|
|
expect(first).toMatch(/^v3:[0-9a-f]{32}:[0-9a-f]+$/);
|
|
expect(second).not.toBe(first);
|
|
|
|
mockFindOnePluginAuth.mockResolvedValue({ value: first });
|
|
await expect(getUserPluginAuthValue('user-id', 'API_KEY')).resolves.toBe('plain');
|
|
});
|
|
|
|
it('stores the legacy fixed-IV format when the write format is legacy', async () => {
|
|
const { encrypt } = jest.requireActual('@librechat/data-schemas');
|
|
mockUpdatePluginAuth.mockImplementation(async (doc) => doc);
|
|
|
|
await updateUserPluginAuth('user-id', 'API_KEY', 'plugin', 'plain', 'legacy');
|
|
|
|
const [[{ value }]] = mockUpdatePluginAuth.mock.calls;
|
|
expect(value).toBe(await encrypt('plain'));
|
|
mockFindOnePluginAuth.mockResolvedValue({ value });
|
|
await expect(getUserPluginAuthValue('user-id', 'API_KEY')).resolves.toBe('plain');
|
|
});
|
|
|
|
it('reads a value stored in the legacy fixed-IV format', async () => {
|
|
const { encrypt } = jest.requireActual('@librechat/data-schemas');
|
|
mockFindOnePluginAuth.mockResolvedValue({ value: await encrypt('legacy-plain') });
|
|
|
|
await expect(getUserPluginAuthValue('user-id', 'API_KEY')).resolves.toBe('legacy-plain');
|
|
});
|
|
});
|