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:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import type { WaggleConnector, ConnectorResult } from './connector-sdk.js';
|
||||
import { getConnectorCredential } from './connectors/connector-credentials.js';
|
||||
import type { ToolDefinition } from './tools.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorDefinition, ConnectorHealth } from '@waggle/shared';
|
||||
@@ -109,7 +110,7 @@ export class ConnectorRegistry {
|
||||
if (this.connectors.get(connector.id) !== connector) return false;
|
||||
if (this.hydration.get(connector)?.status !== 'ready') return false;
|
||||
if (ALWAYS_CONNECTED_CONNECTOR_IDS.has(connector.id)) return true;
|
||||
const cred = this.vault.getConnectorCredential(connector.id);
|
||||
const cred = getConnectorCredential(this.vault, connector.id);
|
||||
return Boolean(
|
||||
cred
|
||||
&& !cred.isExpired
|
||||
@@ -128,7 +129,7 @@ export class ConnectorRegistry {
|
||||
/** Get ConnectorDefinition[] with live status from vault (for REST API responses) */
|
||||
getDefinitions(): ConnectorDefinition[] {
|
||||
return [...this.connectors.values()].map(c => {
|
||||
const cred = this.vault.getConnectorCredential(c.id);
|
||||
const cred = getConnectorCredential(this.vault, c.id);
|
||||
let status: ConnectorDefinition['status'] = 'disconnected';
|
||||
if (cred) {
|
||||
status = cred.isExpired ? 'expired' : (this.isConnected(c) ? 'connected' : 'disconnected');
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -107,7 +108,7 @@ export class AirtableConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -101,7 +102,7 @@ export class AsanaConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -96,7 +97,7 @@ export class BitbucketConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -91,7 +92,7 @@ export class ComposioConnector extends BaseConnector {
|
||||
private apiKey: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.apiKey = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -90,7 +91,7 @@ export class ConfluenceConnector extends BaseConnector {
|
||||
private baseUrl: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
if (!cred) {
|
||||
this.authHeader = null;
|
||||
this.baseUrl = null;
|
||||
|
||||
88
packages/agent/src/connectors/connector-credentials.ts
Normal file
88
packages/agent/src/connectors/connector-credentials.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Connector credentials in the secret store.
|
||||
*
|
||||
* Secret names (the layout existing vault files already use):
|
||||
* connector:<id> token; metadata { credentialType, expiresAt, scopes }
|
||||
* connector:<id>:refresh OAuth refresh token
|
||||
* connector:<id>:<suffix> companion values such as email or base_url
|
||||
* Metadata is stored unencrypted, so tokens and refresh tokens never go there.
|
||||
*/
|
||||
|
||||
import type { SecretStore, SecretWrite } from '@waggle/core';
|
||||
|
||||
export interface ConnectorCredentialInput {
|
||||
type: 'api_key' | 'oauth2' | 'bearer' | 'basic';
|
||||
value: string;
|
||||
refreshToken?: string;
|
||||
expiresAt?: string;
|
||||
scopes?: string[];
|
||||
}
|
||||
|
||||
export interface StoredConnectorCredential {
|
||||
value: string;
|
||||
type: string;
|
||||
refreshToken?: string;
|
||||
expiresAt?: string;
|
||||
scopes?: string[];
|
||||
isExpired: boolean;
|
||||
}
|
||||
|
||||
/** The connector's credential with its refresh token, or null when none is stored. */
|
||||
export function getConnectorCredential(secrets: SecretStore, connectorId: string): StoredConnectorCredential | null {
|
||||
const entry = secrets.get(`connector:${connectorId}`);
|
||||
if (!entry) return null;
|
||||
const expiresAt = entry.metadata?.expiresAt as string | undefined;
|
||||
const refreshEntry = secrets.get(`connector:${connectorId}:refresh`);
|
||||
return {
|
||||
value: entry.value,
|
||||
type: (entry.metadata?.credentialType as string) ?? 'api_key',
|
||||
refreshToken: refreshEntry?.value,
|
||||
expiresAt,
|
||||
scopes: entry.metadata?.scopes as string[] | undefined,
|
||||
isExpired: expiresAt ? new Date(expiresAt) < new Date() : false,
|
||||
};
|
||||
}
|
||||
|
||||
/** Store a connector credential. Storing one without a refresh token removes the old refresh token. */
|
||||
export function setConnectorCredential(
|
||||
secrets: SecretStore,
|
||||
connectorId: string,
|
||||
credential: ConnectorCredentialInput,
|
||||
): void {
|
||||
setConnectorCredentialBundle(secrets, connectorId, credential);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a connector credential and its companion values in one secret-store
|
||||
* update. This prevents a multi-field credential (for example Jira token +
|
||||
* email + site origin) from being partially updated.
|
||||
*/
|
||||
export function setConnectorCredentialBundle(
|
||||
secrets: SecretStore,
|
||||
connectorId: string,
|
||||
credential: ConnectorCredentialInput,
|
||||
relatedSecrets: Readonly<Record<string, string>> = {},
|
||||
): void {
|
||||
const related = Object.entries(relatedSecrets);
|
||||
if (related.some(([suffix]) => !/^[a-z][a-z0-9_]*$/.test(suffix))) {
|
||||
throw new TypeError('Invalid connector credential suffix');
|
||||
}
|
||||
|
||||
const refreshName = `connector:${connectorId}:refresh`;
|
||||
const writes: SecretWrite[] = [{
|
||||
name: `connector:${connectorId}`,
|
||||
value: credential.value,
|
||||
metadata: {
|
||||
credentialType: credential.type,
|
||||
expiresAt: credential.expiresAt,
|
||||
scopes: credential.scopes,
|
||||
},
|
||||
}];
|
||||
if (credential.refreshToken) {
|
||||
writes.push({ name: refreshName, value: credential.refreshToken });
|
||||
}
|
||||
for (const [suffix, value] of related) {
|
||||
writes.push({ name: `connector:${connectorId}:${suffix}`, value });
|
||||
}
|
||||
secrets.writeBatch({ set: writes, delete: credential.refreshToken ? [] : [refreshName] });
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -94,7 +95,7 @@ export class DiscordConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -89,7 +90,7 @@ export class DropboxConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -72,7 +73,7 @@ export class EmailConnector extends BaseConnector {
|
||||
private maxDailyEmails = 100;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.apiKey = cred?.value ?? null;
|
||||
|
||||
// Optional from_email/from_name config
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential, setConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -97,7 +98,7 @@ export class GoogleCalendarConnector extends BaseConnector {
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
this.credentialGeneration += 1;
|
||||
this.vault = vault;
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.accessToken = cred?.value ?? null;
|
||||
this.refreshToken = cred?.refreshToken ?? null;
|
||||
this.expiresAt = cred?.expiresAt ?? null;
|
||||
@@ -190,7 +191,7 @@ export class GoogleCalendarConnector extends BaseConnector {
|
||||
if (!res.ok) throw new Error(`Token refresh failed: ${res.status}`);
|
||||
|
||||
const data = await res.json() as { access_token: string; expires_in: number; refresh_token?: string };
|
||||
const currentCredential = vault?.getConnectorCredential(this.id);
|
||||
const currentCredential = vault ? getConnectorCredential(vault, this.id) : null;
|
||||
if (
|
||||
this.credentialGeneration !== credentialGeneration
|
||||
|| !currentCredential
|
||||
@@ -206,7 +207,7 @@ export class GoogleCalendarConnector extends BaseConnector {
|
||||
|
||||
// Persist updated tokens back to vault
|
||||
if (vault) {
|
||||
vault.setConnectorCredential(this.id, {
|
||||
setConnectorCredential(vault, this.id, {
|
||||
type: 'oauth2',
|
||||
value: this.accessToken,
|
||||
refreshToken: this.refreshToken ?? undefined,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -74,7 +75,7 @@ export class GoogleDocsConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -102,7 +103,7 @@ export class GoogleDriveConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -126,7 +127,7 @@ export class GitHubConnector extends BaseConnector {
|
||||
private baseUrl = API_BASE;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
// Support GitHub Enterprise via connector config
|
||||
const configEntry = vault.get(`connector:${this.id}:base_url`);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -108,7 +109,7 @@ export class GitLabConnector extends BaseConnector {
|
||||
private baseUrl = DEFAULT_API_BASE;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
|
||||
// Support self-hosted GitLab via connector config
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -85,7 +86,7 @@ export class GmailConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -90,7 +91,7 @@ export class GoogleSheetsConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -116,7 +117,7 @@ export class HubSpotConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorDefinition, ConnectorHealth, ConnectorStatus } from '@waggle/shared';
|
||||
|
||||
@@ -131,7 +132,7 @@ export class JiraConnector extends BaseConnector {
|
||||
}
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
if (!cred) {
|
||||
this.authHeader = null;
|
||||
this.baseUrl = null;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -102,7 +103,7 @@ export class LinearConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -91,7 +92,7 @@ export class MondayConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -95,7 +96,7 @@ export class MSTeamsConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -114,7 +115,7 @@ export class NotionConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -105,7 +106,7 @@ export class ObsidianConnector extends BaseConnector {
|
||||
private vaultPath: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.vaultPath = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -83,7 +84,7 @@ export class OneDriveConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -125,7 +126,7 @@ export class OneNoteConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -117,7 +118,7 @@ export class OutlookConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -118,7 +119,7 @@ export class PipedriveConnector extends BaseConnector {
|
||||
private apiToken: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.apiToken = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -90,7 +91,7 @@ export class PostgresConnector extends BaseConnector {
|
||||
private client: PgClient | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.connectionString = cred?.value ?? null;
|
||||
|
||||
// Try to dynamically import pg
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import { safeFetch } from '../url-egress-guard.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorDefinition, ConnectorHealth, ConnectorStatus } from '@waggle/shared';
|
||||
@@ -214,7 +215,7 @@ export class SalesforceConnector extends BaseConnector {
|
||||
}
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
|
||||
// Instance URL from vault metadata (e.g., "https://mycompany.salesforce.com")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -73,7 +74,7 @@ export class SlackConnector extends BaseConnector {
|
||||
private token: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.token = cred?.value ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { BaseConnector, type ConnectorAction, type ConnectorResult } from '../connector-sdk.js';
|
||||
import { getConnectorCredential } from './connector-credentials.js';
|
||||
import type { VaultStore } from '@waggle/core';
|
||||
import type { ConnectorHealth } from '@waggle/shared';
|
||||
|
||||
@@ -109,7 +110,7 @@ export class TrelloConnector extends BaseConnector {
|
||||
private apiToken: string | null = null;
|
||||
|
||||
async connect(vault: VaultStore): Promise<void> {
|
||||
const cred = vault.getConnectorCredential(this.id);
|
||||
const cred = getConnectorCredential(vault, this.id);
|
||||
this.apiToken = cred?.value ?? null;
|
||||
// API key stored as a separate vault entry
|
||||
const keyEntry = vault.get(`connector:${this.id}:api_key`);
|
||||
|
||||
@@ -404,6 +404,10 @@ export {
|
||||
} from './skill-watcher.js';
|
||||
export { BaseConnector, type WaggleConnector, type ConnectorAction, type ConnectorResult } from './connector-sdk.js';
|
||||
export { ConnectorRegistry, type AuditLogger } from './connector-registry.js';
|
||||
export {
|
||||
getConnectorCredential, setConnectorCredential, setConnectorCredentialBundle,
|
||||
type ConnectorCredentialInput, type StoredConnectorCredential,
|
||||
} from './connectors/connector-credentials.js';
|
||||
export {
|
||||
GitHubConnector, SlackConnector, JiraConnector, EmailConnector, GoogleCalendarConnector,
|
||||
DiscordConnector, LinearConnector, AsanaConnector, TrelloConnector, MondayConnector,
|
||||
|
||||
Reference in New Issue
Block a user