godcrm/backend/services/verification/methods/index.js
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

41 lines
1.2 KiB
JavaScript

// ADR-0011 · Phase C · method plugin registry.
//
// Plugin contract:
// {
// name: string,
// verify({ context, submission }) -> Promise<
// | { ok: true, at: string, code_hash: string }
// | { ok: false, code: string, message: string, status?: number }
// >
// }
//
// context: { userId, tableId, rowId, columnId, column, config }
// submission: { method: string, code?: string, token?: string, ... }
import { totpMethod } from './totp.js';
import { captchaMethod } from './captcha.js';
import { smsMethod } from './sms.js';
import { emailMethod } from './email.js';
const registry = new Map();
export function registerMethod(plugin) {
if (!plugin || typeof plugin.name !== 'string' || typeof plugin.verify !== 'function') {
throw new Error('method plugin must expose { name: string, verify: function }');
}
registry.set(plugin.name, plugin);
}
export function getMethod(name) {
return registry.get(name) || null;
}
export function listRegisteredMethods() {
return Array.from(registry.keys());
}
// Bootstrap built-ins on module load.
registerMethod(totpMethod);
registerMethod(captchaMethod);
registerMethod(smsMethod);
registerMethod(emailMethod);