refactor(agent): move the connector credential helpers out of VaultStore (P1.2)
getConnectorCredential, setConnectorCredential and setConnectorCredentialBundle are now plain functions over a SecretStore in packages/agent/src/connectors/connector-credentials.ts. The secret names, metadata layout and the rule that tokens never go into plaintext metadata are unchanged, so existing vault files keep working. A bundle still lands as one update: SecretStore gains writeBatch, which VaultStore applies with a single vault-file replacement. Connector tests seed a Map-backed SecretStore instead of mocking VaultStore methods; the helper tests from core and server moved to the agent package.
This commit is contained in:
@@ -19,6 +19,7 @@ import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import os from 'node:os';
|
||||
import { MindDB, FrameStore, SessionStore, VaultStore } from '@waggle/core';
|
||||
import { getConnectorCredential, setConnectorCredential } from '@waggle/agent';
|
||||
import { buildLocalServer } from '../src/local/index.js';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import { injectWithAuth } from './test-utils.js';
|
||||
@@ -439,13 +440,13 @@ describe('Vault encryption cross-platform', () => {
|
||||
|
||||
it('connector credential helpers work', () => {
|
||||
const vault = new VaultStore(tmpDir);
|
||||
vault.setConnectorCredential('github', {
|
||||
setConnectorCredential(vault, 'github', {
|
||||
type: 'bearer',
|
||||
value: 'ghp_test123',
|
||||
scopes: ['repo', 'read:org'],
|
||||
});
|
||||
|
||||
const cred = vault.getConnectorCredential('github');
|
||||
const cred = getConnectorCredential(vault, 'github');
|
||||
expect(cred).not.toBeNull();
|
||||
expect(cred!.value).toBe('ghp_test123');
|
||||
expect(cred!.type).toBe('bearer');
|
||||
|
||||
Reference in New Issue
Block a user