@vericto/sdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/LICENSE +93 -0
- package/README.md +377 -2
- package/SECURITY.md +58 -0
- package/dist/better-sqlite3.cjs +62 -0
- package/dist/better-sqlite3.cjs.map +1 -0
- package/dist/better-sqlite3.d.cts +64 -0
- package/dist/better-sqlite3.d.ts +64 -0
- package/dist/better-sqlite3.js +58 -0
- package/dist/better-sqlite3.js.map +1 -0
- package/dist/chunk-HFL7W4WC.cjs +600 -0
- package/dist/chunk-HFL7W4WC.cjs.map +1 -0
- package/dist/chunk-I4I35HUY.js +582 -0
- package/dist/chunk-I4I35HUY.js.map +1 -0
- package/dist/guard-BVpq8ytG.d.cts +175 -0
- package/dist/guard-BVpq8ytG.d.ts +175 -0
- package/dist/index.cjs +76 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +76 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/langchain.cjs +195 -0
- package/dist/langchain.cjs.map +1 -0
- package/dist/langchain.d.cts +126 -0
- package/dist/langchain.d.ts +126 -0
- package/dist/langchain.js +186 -0
- package/dist/langchain.js.map +1 -0
- package/dist/snowflake.cjs +51 -0
- package/dist/snowflake.cjs.map +1 -0
- package/dist/snowflake.d.cts +47 -0
- package/dist/snowflake.d.ts +47 -0
- package/dist/snowflake.js +47 -0
- package/dist/snowflake.js.map +1 -0
- package/package.json +83 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dialects.ts","../src/errors.ts","../src/verdict.ts","../src/version.ts","../src/runtime-api.ts","../src/guard.ts"],"names":[],"mappings":";AAKO,IAAM,iBAAiB,CAAC,UAAA,EAAY,SAAS,QAAA,EAAU,OAAA,EAAS,aAAa,QAAQ;AAE5F,IAAM,OAAA,GAA4C;AAAA,EAChD,Q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IAAA,IAAA,CAAK,MAAA,CAAO,IAAI,GAAA,EAAK,EAAE,IAAI,IAAA,CAAK,GAAA,EAAI,EAAG,OAAA,EAAS,CAAA;AAChD,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,IAAA,GAAO,IAAA,CAAK,KAAA,EAAO;AACpC,MAAA,MAAM,SAAS,IAAA,CAAK,MAAA,CAAO,IAAA,EAAK,CAAE,MAAK,CAAE,KAAA;AACzC,MAAA,IAAI,WAAW,MAAA,EAAW;AAC1B,MAAA,IAAA,CAAK,MAAA,CAAO,OAAO,MAAM,CAAA;AAAA,IAC3B;AAAA,EACF;AAAA,EAEA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,OAAO,KAAA,EAAM;AAAA,EACpB;AACF,CAAA","file":"chunk-I4I35HUY.js","sourcesContent":["/**\n * Dialects the Vericto engine evaluates (`sqlite` since vericto-engine 4.1.0). The\n * wrappers still ask the server (`GET /api/v1/meta/config`) and refuse a dialect it\n * does not list.\n */\nexport const KNOWN_DIALECTS = ['postgres', 'mysql', 'oracle', 'mssql', 'snowflake', 'sqlite'] as const;\n\nconst ALIASES: Readonly<Record<string, string>> = {\n postgres: 'postgres',\n postgresql: 'postgres',\n pg: 'postgres',\n mysql: 'mysql',\n mysql2: 'mysql',\n mariadb: 'mysql',\n oracle: 'oracle',\n oracledb: 'oracle',\n mssql: 'mssql',\n sqlserver: 'mssql',\n tedious: 'mssql',\n snowflake: 'snowflake',\n sqlite: 'sqlite',\n sqlite3: 'sqlite',\n 'better-sqlite3': 'sqlite',\n};\n\n/**\n * Map a driver name to the Vericto dialect id. Unknown names pass through\n * lower-cased: the server decides, and answers with a clear error.\n */\nexport function normalizeDialect(name: string): string {\n const key = name.trim().toLowerCase();\n return ALIASES[key] ?? key;\n}\n","import type { Finding, Verdict } from './verdict.js';\n\n/** Base class of every error this package throws. */\nexport class VerictoError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\n/**\n * The client is misconfigured: missing or rejected API key, bad database id, a key\n * without the `proxy:evaluate` scope, or a malformed request. Thrown whatever the\n * fail mode is: failing open on a revoked key would switch the firewall off silently.\n */\nexport class VerictoConfigError extends VerictoError {\n readonly status: number | undefined;\n readonly code: string | undefined;\n\n constructor(message: string, options: { status?: number; code?: string } = {}) {\n super(message);\n this.status = options.status;\n this.code = options.code;\n }\n}\n\n/**\n * The Vericto server does not evaluate this dialect (it is missing from\n * `GET /api/v1/meta/config`, e.g. `sqlite` on a server older than vericto-engine\n * 4.1.0). No SQL was executed.\n */\nexport class VerictoUnsupportedDialectError extends VerictoConfigError {\n readonly dialect: string;\n readonly supported: readonly string[];\n\n constructor(dialect: string, supported: readonly string[], apiUrl: string) {\n const listed = supported.length ? supported.join(', ') : 'none reported';\n super(\n `The Vericto API at ${apiUrl} does not support the '${dialect}' dialect (supported: ${listed}). ` +\n 'No SQL was executed. Upgrade the server, or use a supported dialect.',\n { code: 'UNSUPPORTED_DIALECT' },\n );\n this.dialect = dialect;\n this.supported = supported;\n }\n}\n\n/**\n * Vericto could not return a verdict after the configured retries. With\n * `failMode: 'closed'` (the default) the statement is not executed and this is thrown.\n */\nexport class VerictoUnavailableError extends VerictoError {\n readonly status: number | undefined;\n readonly code: string | undefined;\n\n constructor(message: string, options: { status?: number; code?: string } = {}) {\n super(message);\n this.status = options.status;\n this.code = options.code;\n }\n}\n\n/** The workspace used its monthly query quota (HTTP 429 `QUOTA_EXCEEDED`). Not retried. */\nexport class VerictoQuotaExceededError extends VerictoUnavailableError {\n readonly resetsAt: string | undefined;\n readonly upgradeUrl: string | undefined;\n\n constructor(message: string, options: { resetsAt?: string; upgradeUrl?: string } = {}) {\n super(message, { status: 429, code: 'QUOTA_EXCEEDED' });\n this.resetsAt = options.resetsAt;\n this.upgradeUrl = options.upgradeUrl;\n }\n}\n\n/** Vericto blocked the statement. It was not executed. */\nexport class VerictoBlockedError extends VerictoError {\n readonly verdict: Verdict;\n readonly sql: string;\n\n constructor(verdict: Verdict, sql: string) {\n let message = `Query blocked by ${verdict.ruleCode ?? 'a Vericto rule'}`;\n if (verdict.severity) message += ` (severity ${verdict.severity})`;\n if (verdict.message) message += `: ${verdict.message}`;\n if (verdict.suggestedFix) message += `. Suggested fix: ${verdict.suggestedFix}`;\n super(message);\n this.verdict = verdict;\n this.sql = sql;\n }\n\n get findings(): readonly Finding[] {\n return this.verdict.findings;\n }\n\n get suggestedFix(): string | undefined {\n return this.verdict.suggestedFix;\n }\n}\n","/**\n * What Vericto decided. `UNEVALUATED` is local: Vericto could not answer and the\n * guard runs with `failMode: 'open'`, so the statement ran without a verdict.\n */\nexport type Decision = 'ALLOWED' | 'FLAGGED' | 'MONITORED' | 'PARSE_ERROR' | 'BLOCKED' | 'UNEVALUATED';\n\nconst SERVER_DECISIONS: ReadonlySet<string> = new Set(['ALLOWED', 'FLAGGED', 'MONITORED', 'PARSE_ERROR', 'BLOCKED']);\n\n/** A rule that matched the statement. */\nexport interface Finding {\n readonly ruleCode: string;\n readonly severity?: string;\n readonly ruleId?: string;\n readonly astNodePath?: string;\n readonly suggestedFix?: string;\n}\n\n/** Vericto's answer for one statement. */\nexport interface Verdict {\n readonly decision: Decision;\n /** The statement as submitted. */\n readonly sql: string;\n readonly dialect: string;\n readonly ruleCode?: string;\n readonly severity?: string;\n readonly message?: string;\n readonly suggestedFix?: string;\n /**\n * When set, the statement to run **instead of** `sql`: the sensitive columns it\n * reads come back masked (Sensitive Column Protection).\n */\n readonly rewrittenQuery?: string;\n readonly parseError?: string;\n readonly findings: readonly Finding[];\n readonly sensitiveColumns: readonly unknown[];\n readonly accessDenied: readonly unknown[];\n /** The audit-trail event id. */\n readonly eventId?: string;\n readonly rulesetVersion?: string;\n readonly cached: boolean;\n /** The response body, for fields this version does not model yet. */\n readonly raw: Readonly<Record<string, unknown>>;\n}\n\n/** The statement the driver must run: the masked rewrite when there is one. */\nexport function sqlToExecute(verdict: Verdict): string {\n return verdict.rewrittenQuery ?? verdict.sql;\n}\n\nexport function isMasked(verdict: Verdict): boolean {\n return Boolean(verdict.rewrittenQuery);\n}\n\n/** Build a verdict from a `POST /api/v1/proxy/query` response body. */\nexport function verdictFromResponse(body: Record<string, unknown>, sql: string, dialect: string): Verdict {\n const raw = (typeof body.decision === 'string' ? body.decision : '').toUpperCase();\n // An unknown decision must never be read as \"allowed\".\n const decision: Decision = SERVER_DECISIONS.has(raw) ? (raw as Decision) : 'BLOCKED';\n const ruleCode = optStr(body.rule_code);\n const severity = optStr(body.severity);\n const suggestedFix = optStr(body.suggested_safe_query);\n let message = optStr(body.error);\n if (message && ruleCode && message === `Query blocked by rule ${ruleCode}`) message = undefined;\n return {\n decision,\n sql,\n dialect,\n ruleCode,\n severity,\n message,\n suggestedFix,\n // A blocked statement never runs, so it has nothing to rewrite.\n rewrittenQuery: decision === 'BLOCKED' ? undefined : optStr(body.rewritten_query),\n parseError: optStr(body.parse_error),\n findings: findingsOf(body, ruleCode, severity, suggestedFix),\n sensitiveColumns: Array.isArray(body.sensitive_columns) ? body.sensitive_columns : [],\n accessDenied: Array.isArray(body.access_denied) ? body.access_denied : [],\n eventId: optStr(body.event_id),\n rulesetVersion: optStr(body.ruleset_version),\n cached: false,\n raw: body,\n };\n}\n\nexport function unevaluatedVerdict(sql: string, dialect: string, reason: string): Verdict {\n return {\n decision: 'UNEVALUATED',\n sql,\n dialect,\n message: reason,\n findings: [],\n sensitiveColumns: [],\n accessDenied: [],\n cached: false,\n raw: {},\n };\n}\n\nfunction optStr(value: unknown): string | undefined {\n if (value === null || value === undefined || value === '') return undefined;\n return typeof value === 'string' ? value : JSON.stringify(value);\n}\n\nfunction findingsOf(\n body: Record<string, unknown>,\n ruleCode: string | undefined,\n severity: string | undefined,\n suggestedFix: string | undefined,\n): Finding[] {\n // The Runtime API reports the deciding rule; a later version may send the full list.\n const listed = body.findings ?? body.violations;\n if (Array.isArray(listed)) {\n const out: Finding[] = [];\n for (const item of listed as unknown[]) {\n if (!item || typeof item !== 'object') continue;\n const f = item as Record<string, unknown>;\n const code = optStr(f.rule_code ?? f.code);\n if (!code) continue;\n out.push({\n ruleCode: code,\n severity: optStr(f.severity),\n ruleId: optStr(f.rule_id),\n astNodePath: optStr(f.ast_node_path),\n suggestedFix: optStr(f.suggested_safe_query ?? f.suggested_fix),\n });\n }\n if (out.length) return out;\n }\n if (!ruleCode) return [];\n return [\n {\n ruleCode,\n severity,\n ruleId: optStr(body.rule_id),\n astNodePath: optStr(body.ast_node_path),\n suggestedFix,\n },\n ];\n}\n","/** The package version (kept in sync with package.json by a test). */\nexport const VERSION = '0.2.0';\n","import {\n VerictoConfigError,\n VerictoQuotaExceededError,\n VerictoUnavailableError,\n VerictoUnsupportedDialectError,\n} from './errors.js';\nimport type { Evaluator } from './evaluator.js';\nimport { verdictFromResponse, type Verdict } from './verdict.js';\nimport { VERSION } from './version.js';\n\nexport const DEFAULT_API_URL = 'https://api.vericto.com';\nexport const EVALUATE_PATH = '/api/v1/proxy/query';\nexport const CONFIG_PATH = '/api/v1/meta/config';\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst RETRYABLE = new Set([500, 502, 503, 504]);\nconst LOCAL_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\nconst MAX_BACKOFF_MS = 2000;\n\ntype FetchLike = (input: string, init: RequestInit) => Promise<Response>;\n\nexport interface RuntimeApiOptions {\n /** API key (`vtro_...`, scope `proxy:evaluate`). Default: `VERICTO_API_KEY`. */\n apiKey?: string;\n /** The registered database (UUID). Default: `VERICTO_DATABASE_ID`. */\n databaseId?: string;\n /** API base URL. Default: `VERICTO_API_URL`, then `https://api.vericto.com`. */\n apiUrl?: string;\n /** Per-attempt timeout in milliseconds. Default: `VERICTO_TIMEOUT` (seconds) or 5000. */\n timeoutMs?: number;\n /** Retries after the first attempt for network errors, timeouts, 5xx and 429 rate limits. Default 2. */\n maxRetries?: number;\n /** Base backoff in milliseconds (exponential, with jitter, capped at 2 s). Default 200. */\n backoffMs?: number;\n /** How long the server's dialect list is cached, in milliseconds. Default 10 minutes. */\n dialectsTtlMs?: number;\n /** A `fetch` implementation (tests, proxies). Default: the global `fetch`. */\n fetch?: FetchLike;\n /** Environment to read the defaults from. Default: `process.env`. */\n env?: Record<string, string | undefined>;\n}\n\n/**\n * Evaluates statements with the Vericto Runtime API (`POST /api/v1/proxy/query`).\n *\n * The key is sent in the `X-API-Key` header, over HTTPS only (plain HTTP is accepted\n * for localhost alone), and never appears in messages or `toString()`. To trust an\n * extra CA, use Node's `NODE_EXTRA_CA_CERTS`.\n */\nexport class RuntimeApiEvaluator implements Evaluator {\n readonly apiUrl: string;\n readonly databaseId: string;\n readonly timeoutMs: number;\n readonly maxRetries: number;\n readonly #apiKey: string;\n readonly #backoffMs: number;\n readonly #dialectsTtlMs: number;\n readonly #fetch: FetchLike;\n #dialects: readonly string[] | undefined;\n #dialectsAt = 0;\n #dialectsPending: Promise<readonly string[] | undefined> | undefined;\n\n constructor(options: RuntimeApiOptions = {}) {\n const env = options.env ?? (typeof process !== 'undefined' ? process.env : {});\n const key = (options.apiKey ?? env.VERICTO_API_KEY ?? '').trim();\n if (!key) {\n throw new VerictoConfigError(\n 'No Vericto API key: pass apiKey or set VERICTO_API_KEY (a vtro_... key with the proxy:evaluate scope).',\n );\n }\n if (!key.startsWith('vtro_')) {\n throw new VerictoConfigError(\"The Vericto API key must start with 'vtro_' (the value itself is not shown).\");\n }\n this.#apiKey = key;\n\n const db = (options.databaseId ?? env.VERICTO_DATABASE_ID ?? '').trim();\n if (!db) {\n throw new VerictoConfigError(\n 'No Vericto database id: pass databaseId or set VERICTO_DATABASE_ID ' +\n '(the id of the database registered in your Vericto workspace).',\n );\n }\n if (!UUID_RE.test(db)) {\n throw new VerictoConfigError(`The Vericto database id must be a UUID, got ${JSON.stringify(db.slice(0, 64))}.`);\n }\n this.databaseId = db.toLowerCase();\n\n const url = ((options.apiUrl ?? env.VERICTO_API_URL ?? '').trim() || DEFAULT_API_URL).replace(/\\/+$/, '');\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n throw new VerictoConfigError(`Invalid Vericto API URL ${JSON.stringify(url)}: expected https://host.`);\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new VerictoConfigError(`Invalid Vericto API URL ${JSON.stringify(url)}: expected https://host.`);\n }\n if (parsed.protocol === 'http:' && !LOCAL_HOSTS.has(parsed.hostname)) {\n throw new VerictoConfigError(`Refusing to send the API key over plain HTTP to ${parsed.hostname}: use https://.`);\n }\n this.apiUrl = url;\n\n let timeoutMs = options.timeoutMs;\n if (timeoutMs === undefined) {\n const fromEnv = (env.VERICTO_TIMEOUT ?? '').trim();\n timeoutMs = fromEnv ? Number(fromEnv) * 1000 : 5000;\n if (!Number.isFinite(timeoutMs)) {\n throw new VerictoConfigError(`VERICTO_TIMEOUT must be a number of seconds, got ${JSON.stringify(fromEnv)}.`);\n }\n }\n if (!(timeoutMs > 0)) throw new VerictoConfigError('timeoutMs must be greater than 0.');\n const maxRetries = options.maxRetries ?? 2;\n if (!(maxRetries >= 0)) throw new VerictoConfigError('maxRetries cannot be negative.');\n this.timeoutMs = timeoutMs;\n this.maxRetries = Math.floor(maxRetries);\n this.#backoffMs = Math.max(0, options.backoffMs ?? 200);\n this.#dialectsTtlMs = options.dialectsTtlMs ?? 600_000;\n // Typed as optional: Node < 18 has no global fetch.\n const f = options.fetch ?? (globalThis as { fetch?: FetchLike }).fetch;\n if (!f) throw new VerictoConfigError('No fetch implementation: Node 18+ is required, or pass options.fetch.');\n this.#fetch = f;\n }\n\n toString(): string {\n return `RuntimeApiEvaluator(apiUrl=${this.apiUrl}, databaseId=${this.databaseId})`;\n }\n\n toJSON(): Record<string, unknown> {\n return { apiUrl: this.apiUrl, databaseId: this.databaseId };\n }\n\n async evaluate(sql: string, dialect: string): Promise<Verdict> {\n const payload = JSON.stringify({ query: sql, database_id: this.databaseId, dialect });\n let lastError = 'no attempt made';\n let retryAfterMs: number | undefined;\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) await sleep(this.#delay(attempt, retryAfterMs));\n retryAfterMs = undefined;\n\n let response: Response;\n try {\n response = await this.#request(EVALUATE_PATH, {\n method: 'POST',\n headers: { ...this.#headers(), 'Content-Type': 'application/json', 'X-API-Key': this.#apiKey },\n body: payload,\n });\n } catch (err) {\n lastError = `${errorName(err)} while calling ${this.apiUrl}`;\n continue;\n }\n\n const status = response.status;\n const body = await jsonBody(response);\n if (status === 200 || (status === 403 && (typeof body.decision === 'string' ? body.decision : '').toUpperCase() === 'BLOCKED')) {\n if (!('decision' in body)) {\n lastError = `HTTP ${status} without a decision from ${this.apiUrl}`;\n continue;\n }\n return verdictFromResponse(body, sql, dialect);\n }\n\n const error = body.error && typeof body.error === 'object' ? (body.error as Record<string, unknown>) : {};\n const code = typeof error.code === 'string' && error.code ? error.code : undefined;\n const message = typeof error.message === 'string' && error.message ? error.message : undefined;\n\n if (status === 429 && code === 'QUOTA_EXCEEDED') {\n const resetsAt = typeof error.resets_at === 'string' ? error.resets_at : undefined;\n throw new VerictoQuotaExceededError(\n `The Vericto workspace has used its monthly query quota${resetsAt ? `; it resets at ${resetsAt}` : ''}.`,\n { resetsAt, upgradeUrl: typeof error.upgrade_url === 'string' ? error.upgrade_url : undefined },\n );\n }\n if (status === 429 || RETRYABLE.has(status)) {\n lastError = `HTTP ${status}${code ? ` ${code}` : ''} from ${this.apiUrl}`;\n retryAfterMs = retryAfter(response.headers.get('retry-after'), error.retry_after_seconds);\n continue;\n }\n throw await this.#configError(status, code, message, dialect);\n }\n throw new VerictoUnavailableError(\n `Vericto did not return a verdict after ${this.maxRetries + 1} attempt(s): ${lastError}.`,\n );\n }\n\n /**\n * The dialects the server evaluates (`GET /api/v1/meta/config`), cached. `undefined`\n * when the server cannot be asked; the evaluation request then decides.\n */\n async supportedDialects(): Promise<readonly string[] | undefined> {\n if (this.#dialects && Date.now() - this.#dialectsAt < this.#dialectsTtlMs) return this.#dialects;\n this.#dialectsPending ??= this.#fetchDialects().finally(() => {\n this.#dialectsPending = undefined;\n });\n return this.#dialectsPending;\n }\n\n async #fetchDialects(): Promise<readonly string[] | undefined> {\n try {\n const response = await this.#request(CONFIG_PATH, { method: 'GET', headers: this.#headers() });\n if (response.status !== 200) return this.#dialects;\n const listed = (await jsonBody(response)).dialects;\n if (!Array.isArray(listed)) return this.#dialects;\n const ids = listed\n .map((d: unknown) => (d && typeof d === 'object' ? (d as Record<string, unknown>).id : undefined))\n .filter((id): id is string => typeof id === 'string' && id.length > 0);\n this.#dialects = ids;\n this.#dialectsAt = Date.now();\n return ids;\n } catch {\n return this.#dialects;\n }\n }\n\n #headers(): Record<string, string> {\n return { Accept: 'application/json', 'User-Agent': `vericto-node/${VERSION}` };\n }\n\n async #request(path: string, init: RequestInit): Promise<Response> {\n const controller = new AbortController();\n const timer = setTimeout(() => { controller.abort(); }, this.timeoutMs);\n try {\n return await this.#fetch(this.apiUrl + path, { ...init, redirect: 'manual', signal: controller.signal });\n } finally {\n clearTimeout(timer);\n }\n }\n\n #delay(attempt: number, retryAfterMs: number | undefined): number {\n if (retryAfterMs !== undefined) return Math.min(retryAfterMs, MAX_BACKOFF_MS);\n const base = this.#backoffMs * 2 ** (attempt - 1);\n return Math.min(MAX_BACKOFF_MS, base * (0.5 + Math.random() / 2));\n }\n\n async #configError(\n status: number,\n code: string | undefined,\n message: string | undefined,\n dialect: string,\n ): Promise<VerictoConfigError> {\n if (status === 401) {\n return new VerictoConfigError('Vericto rejected the API key (HTTP 401). Check VERICTO_API_KEY.', {\n status,\n code,\n });\n }\n if (status === 403) {\n return new VerictoConfigError(\n `Vericto refused the request (HTTP 403${code ? `, ${code}` : ''}): ` +\n `${message ?? 'the key lacks the proxy:evaluate scope or this database'}.`,\n { status, code },\n );\n }\n if (status === 400) {\n const supported = await this.supportedDialects();\n if (supported && !supported.includes(dialect)) {\n return new VerictoUnsupportedDialectError(dialect, supported, this.apiUrl);\n }\n }\n return new VerictoConfigError(\n `Vericto rejected the request (HTTP ${status}${code ? `, ${code}` : ''})${message ? `: ${message}` : '.'}`,\n { status, code },\n );\n }\n}\n\nasync function jsonBody(response: Response): Promise<Record<string, unknown>> {\n try {\n const text = await response.text();\n const parsed: unknown = text ? JSON.parse(text) : {};\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n}\n\nfunction retryAfter(header: string | null, bodyValue: unknown): number | undefined {\n for (const value of [header, bodyValue]) {\n if (value === null || value === undefined || value === '') continue;\n const seconds = Number(value);\n if (Number.isFinite(seconds)) return Math.max(0, seconds * 1000);\n }\n return undefined;\n}\n\nfunction errorName(err: unknown): string {\n if (err instanceof Error) return err.name === 'AbortError' ? 'Timeout' : err.name;\n return 'Error';\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","import { normalizeDialect } from './dialects.js';\nimport {\n VerictoBlockedError,\n VerictoConfigError,\n VerictoUnavailableError,\n VerictoUnsupportedDialectError,\n} from './errors.js';\nimport type { Evaluator } from './evaluator.js';\nimport { RuntimeApiEvaluator, type RuntimeApiOptions } from './runtime-api.js';\nimport { isMasked, sqlToExecute, unevaluatedVerdict, type Verdict } from './verdict.js';\n\nexport type FailMode = 'closed' | 'open';\n\n/** Where the guard reports. The SQL text is never passed to it. */\nexport interface VerictoLogger {\n info(message: string): void;\n warn(message: string): void;\n error(message: string): void;\n}\n\nexport interface VerictoOptions extends RuntimeApiOptions {\n /** What evaluates statements. Default: a `RuntimeApiEvaluator` from the options above. */\n evaluator?: Evaluator;\n /**\n * `closed` (default, or `VERICTO_FAIL_MODE`): when Vericto cannot answer, reject with\n * `VerictoUnavailableError` and do not run the statement. `open`: run it unevaluated,\n * emit a process warning (`VerictoFailOpenWarning`) and log it.\n */\n failMode?: FailMode;\n /** Milliseconds to reuse a verdict for the same `(sql, dialect)`. 0 (default) disables it. */\n cacheTtlMs?: number;\n /** Maximum cached verdicts. Default 1024. */\n cacheSize?: number;\n /** Called with every verdict, including `UNEVALUATED` and `BLOCKED` ones. */\n onVerdict?: (verdict: Verdict) => void;\n /** Default: `console` for warnings and errors, silent for info. `false` silences it. */\n logger?: VerictoLogger | false;\n}\n\nconst DEFAULT_LOGGER: VerictoLogger = {\n info: () => {},\n warn: (m) => { console.warn(m); },\n error: (m) => { console.error(m); },\n};\nconst SILENT: VerictoLogger = { info: () => {}, warn: () => {}, error: () => {} };\n\n/**\n * Checks SQL with Vericto before it runs. Share one instance per process; the\n * wrappers call `enforce` for every statement, and you can call it yourself around\n * any other driver.\n */\nexport class Vericto {\n readonly evaluator: Evaluator;\n readonly failMode: FailMode;\n readonly onVerdict: ((verdict: Verdict) => void) | undefined;\n readonly #logger: VerictoLogger;\n readonly #cache: VerdictCache | undefined;\n\n constructor(options: VerictoOptions = {}) {\n this.evaluator = options.evaluator ?? new RuntimeApiEvaluator(options);\n const env = options.env ?? (typeof process !== 'undefined' ? process.env : {});\n const mode = (options.failMode ?? env.VERICTO_FAIL_MODE ?? 'closed').trim().toLowerCase();\n if (mode !== 'closed' && mode !== 'open') {\n throw new VerictoConfigError(`failMode must be 'closed' or 'open', got ${JSON.stringify(mode)}.`);\n }\n this.failMode = mode;\n const ttl = options.cacheTtlMs ?? 0;\n const size = options.cacheSize ?? 1024;\n if (ttl < 0 || size < 1) throw new VerictoConfigError('cacheTtlMs must be >= 0 and cacheSize >= 1.');\n this.#cache = ttl > 0 ? new VerdictCache(ttl, size) : undefined;\n this.onVerdict = options.onVerdict;\n this.#logger = options.logger === false ? SILENT : (options.logger ?? DEFAULT_LOGGER);\n }\n\n /**\n * Fail fast if the server reports that it does not evaluate `dialect`. Resolves the\n * normalized dialect id. When the server cannot be asked, nothing is thrown here.\n */\n async requireDialect(dialect: string): Promise<string> {\n const name = normalizeDialect(dialect);\n const supported = await this.evaluator.supportedDialects();\n if (supported && !supported.includes(name)) {\n throw new VerictoUnsupportedDialectError(name, supported, this.evaluator.apiUrl ?? 'the configured evaluator');\n }\n return name;\n }\n\n /**\n * Evaluate `sql` and resolve the verdict, whatever it is. Does not apply the fail\n * mode and does not reject on `BLOCKED`: use it to ask, and `enforce` to guard.\n */\n async check(sql: string, dialect: string): Promise<Verdict> {\n if (typeof sql !== 'string') {\n throw new TypeError(`vericto: expected the SQL text as a string, got ${typeof sql}.`);\n }\n const name = await this.requireDialect(dialect);\n const hit = this.#cache?.get(sql, name);\n if (hit) return hit;\n const verdict = await this.evaluator.evaluate(sql, name);\n this.#cache?.put(verdict);\n return verdict;\n }\n\n /**\n * Evaluate `sql` and apply the decision: reject with `VerictoBlockedError` on\n * `BLOCKED`; log `FLAGGED`/`MONITORED`/allowed `PARSE_ERROR`; apply the fail mode\n * when Vericto cannot answer. Run `sqlToExecute(verdict)` (the masked rewrite, if any).\n */\n async enforce(sql: string, dialect: string): Promise<Verdict> {\n let verdict: Verdict;\n try {\n verdict = await this.check(sql, dialect);\n } catch (err) {\n if (!(err instanceof VerictoUnavailableError)) throw err;\n if (this.failMode === 'closed') {\n this.#logger.error(`vericto: no verdict, statement not executed (failMode=closed): ${err.message}`);\n throw err;\n }\n verdict = unevaluatedVerdict(sql, normalizeDialect(dialect), err.message);\n this.#logger.warn(`vericto: no verdict, statement executed unevaluated (failMode=open): ${err.message}`);\n emitFailOpenWarning(err.message);\n this.#notify(verdict);\n return verdict;\n }\n this.#notify(verdict);\n this.#log(verdict);\n if (verdict.decision === 'BLOCKED') throw new VerictoBlockedError(verdict, sql);\n return verdict;\n }\n\n /** `enforce`, resolving the SQL text to execute. */\n async prepare(sql: string, dialect: string): Promise<string> {\n return sqlToExecute(await this.enforce(sql, dialect));\n }\n\n /** Enforce a batch in order; a block anywhere rejects before the caller runs any of it. */\n async enforceAll(statements: readonly string[], dialect: string): Promise<Verdict[]> {\n const out: Verdict[] = [];\n for (const statement of statements) out.push(await this.enforce(statement, dialect));\n return out;\n }\n\n clearCache(): void {\n this.#cache?.clear();\n }\n\n #notify(verdict: Verdict): void {\n if (!this.onVerdict) return;\n try {\n this.onVerdict(verdict);\n } catch (err) {\n // A broken callback must not change the decision.\n this.#logger.error(`vericto: onVerdict callback threw: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n #log(verdict: Verdict): void {\n // The SQL text is never logged: it can carry personal data in literals.\n const extra = `rule=${verdict.ruleCode ?? '-'} severity=${verdict.severity ?? '-'} event_id=${verdict.eventId ?? '-'}`;\n switch (verdict.decision) {\n case 'BLOCKED':\n this.#logger.warn(`vericto: statement BLOCKED ${extra}`);\n break;\n case 'FLAGGED':\n this.#logger.warn(`vericto: statement FLAGGED ${extra}`);\n break;\n case 'PARSE_ERROR':\n this.#logger.warn(`vericto: statement not parsed, allowed by workspace policy ${extra}`);\n break;\n case 'MONITORED':\n this.#logger.info(`vericto: statement MONITORED ${extra}`);\n break;\n default:\n break;\n }\n if (isMasked(verdict)) this.#logger.info(`vericto: running the masked rewrite ${extra}`);\n }\n}\n\nfunction emitFailOpenWarning(reason: string): void {\n if (typeof process !== 'undefined' && typeof process.emitWarning === 'function') {\n process.emitWarning(`Vericto could not evaluate the statement and failMode is 'open', so it ran unchecked: ${reason}`, {\n type: 'VerictoFailOpenWarning',\n code: 'VERICTO_FAIL_OPEN',\n });\n }\n}\n\n/**\n * Small TTL + LRU cache of server verdicts, keyed by `(sql, dialect)`. Dropped whole\n * when a response reports a different `ruleset_version`.\n */\nclass VerdictCache {\n readonly #ttl: number;\n readonly #size: number;\n readonly #items = new Map<string, { at: number; verdict: Verdict }>();\n #ruleset: string | undefined;\n\n constructor(ttl: number, size: number) {\n this.#ttl = ttl;\n this.#size = size;\n }\n\n get(sql: string, dialect: string): Verdict | undefined {\n const key = `${dialect}\\u0000${sql}`;\n const item = this.#items.get(key);\n if (!item) return undefined;\n if (Date.now() - item.at > this.#ttl) {\n this.#items.delete(key);\n return undefined;\n }\n this.#items.delete(key);\n this.#items.set(key, item);\n return { ...item.verdict, cached: true };\n }\n\n put(verdict: Verdict): void {\n if (verdict.decision === 'UNEVALUATED') return;\n if (verdict.rulesetVersion && verdict.rulesetVersion !== this.#ruleset) {\n if (this.#ruleset !== undefined) this.#items.clear();\n this.#ruleset = verdict.rulesetVersion;\n }\n const key = `${verdict.dialect}\\u0000${verdict.sql}`;\n this.#items.delete(key);\n this.#items.set(key, { at: Date.now(), verdict });\n while (this.#items.size > this.#size) {\n const oldest = this.#items.keys().next().value;\n if (oldest === undefined) break;\n this.#items.delete(oldest);\n }\n }\n\n clear(): void {\n this.#items.clear();\n }\n}\n"]}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Vericto decided. `UNEVALUATED` is local: Vericto could not answer and the
|
|
3
|
+
* guard runs with `failMode: 'open'`, so the statement ran without a verdict.
|
|
4
|
+
*/
|
|
5
|
+
type Decision = 'ALLOWED' | 'FLAGGED' | 'MONITORED' | 'PARSE_ERROR' | 'BLOCKED' | 'UNEVALUATED';
|
|
6
|
+
/** A rule that matched the statement. */
|
|
7
|
+
interface Finding {
|
|
8
|
+
readonly ruleCode: string;
|
|
9
|
+
readonly severity?: string;
|
|
10
|
+
readonly ruleId?: string;
|
|
11
|
+
readonly astNodePath?: string;
|
|
12
|
+
readonly suggestedFix?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Vericto's answer for one statement. */
|
|
15
|
+
interface Verdict {
|
|
16
|
+
readonly decision: Decision;
|
|
17
|
+
/** The statement as submitted. */
|
|
18
|
+
readonly sql: string;
|
|
19
|
+
readonly dialect: string;
|
|
20
|
+
readonly ruleCode?: string;
|
|
21
|
+
readonly severity?: string;
|
|
22
|
+
readonly message?: string;
|
|
23
|
+
readonly suggestedFix?: string;
|
|
24
|
+
/**
|
|
25
|
+
* When set, the statement to run **instead of** `sql`: the sensitive columns it
|
|
26
|
+
* reads come back masked (Sensitive Column Protection).
|
|
27
|
+
*/
|
|
28
|
+
readonly rewrittenQuery?: string;
|
|
29
|
+
readonly parseError?: string;
|
|
30
|
+
readonly findings: readonly Finding[];
|
|
31
|
+
readonly sensitiveColumns: readonly unknown[];
|
|
32
|
+
readonly accessDenied: readonly unknown[];
|
|
33
|
+
/** The audit-trail event id. */
|
|
34
|
+
readonly eventId?: string;
|
|
35
|
+
readonly rulesetVersion?: string;
|
|
36
|
+
readonly cached: boolean;
|
|
37
|
+
/** The response body, for fields this version does not model yet. */
|
|
38
|
+
readonly raw: Readonly<Record<string, unknown>>;
|
|
39
|
+
}
|
|
40
|
+
/** The statement the driver must run: the masked rewrite when there is one. */
|
|
41
|
+
declare function sqlToExecute(verdict: Verdict): string;
|
|
42
|
+
declare function isMasked(verdict: Verdict): boolean;
|
|
43
|
+
/** Build a verdict from a `POST /api/v1/proxy/query` response body. */
|
|
44
|
+
declare function verdictFromResponse(body: Record<string, unknown>, sql: string, dialect: string): Verdict;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Turns `(sql, dialect)` into a verdict.
|
|
48
|
+
*
|
|
49
|
+
* This release ships one implementation, `RuntimeApiEvaluator`, which asks the Vericto
|
|
50
|
+
* Runtime API. An embedded evaluator (the engine in-process, for example as WASM or a
|
|
51
|
+
* native addon with synced rules) can be added later behind the same interface
|
|
52
|
+
* without touching the wrappers.
|
|
53
|
+
*
|
|
54
|
+
* Implementations resolve a verdict for every evaluated statement (`BLOCKED`
|
|
55
|
+
* included: blocking is the guard's job), reject with `VerictoUnavailableError` when
|
|
56
|
+
* no verdict can be produced, and with `VerictoConfigError` when the request can
|
|
57
|
+
* never succeed.
|
|
58
|
+
*/
|
|
59
|
+
interface Evaluator {
|
|
60
|
+
evaluate(sql: string, dialect: string): Promise<Verdict>;
|
|
61
|
+
/** The dialects this evaluator handles, or `undefined` when it cannot tell. */
|
|
62
|
+
supportedDialects(): Promise<readonly string[] | undefined>;
|
|
63
|
+
/** Shown in error messages. */
|
|
64
|
+
readonly apiUrl?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare const DEFAULT_API_URL = "https://api.vericto.com";
|
|
68
|
+
declare const EVALUATE_PATH = "/api/v1/proxy/query";
|
|
69
|
+
declare const CONFIG_PATH = "/api/v1/meta/config";
|
|
70
|
+
type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
|
|
71
|
+
interface RuntimeApiOptions {
|
|
72
|
+
/** API key (`vtro_...`, scope `proxy:evaluate`). Default: `VERICTO_API_KEY`. */
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
/** The registered database (UUID). Default: `VERICTO_DATABASE_ID`. */
|
|
75
|
+
databaseId?: string;
|
|
76
|
+
/** API base URL. Default: `VERICTO_API_URL`, then `https://api.vericto.com`. */
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
/** Per-attempt timeout in milliseconds. Default: `VERICTO_TIMEOUT` (seconds) or 5000. */
|
|
79
|
+
timeoutMs?: number;
|
|
80
|
+
/** Retries after the first attempt for network errors, timeouts, 5xx and 429 rate limits. Default 2. */
|
|
81
|
+
maxRetries?: number;
|
|
82
|
+
/** Base backoff in milliseconds (exponential, with jitter, capped at 2 s). Default 200. */
|
|
83
|
+
backoffMs?: number;
|
|
84
|
+
/** How long the server's dialect list is cached, in milliseconds. Default 10 minutes. */
|
|
85
|
+
dialectsTtlMs?: number;
|
|
86
|
+
/** A `fetch` implementation (tests, proxies). Default: the global `fetch`. */
|
|
87
|
+
fetch?: FetchLike;
|
|
88
|
+
/** Environment to read the defaults from. Default: `process.env`. */
|
|
89
|
+
env?: Record<string, string | undefined>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Evaluates statements with the Vericto Runtime API (`POST /api/v1/proxy/query`).
|
|
93
|
+
*
|
|
94
|
+
* The key is sent in the `X-API-Key` header, over HTTPS only (plain HTTP is accepted
|
|
95
|
+
* for localhost alone), and never appears in messages or `toString()`. To trust an
|
|
96
|
+
* extra CA, use Node's `NODE_EXTRA_CA_CERTS`.
|
|
97
|
+
*/
|
|
98
|
+
declare class RuntimeApiEvaluator implements Evaluator {
|
|
99
|
+
#private;
|
|
100
|
+
readonly apiUrl: string;
|
|
101
|
+
readonly databaseId: string;
|
|
102
|
+
readonly timeoutMs: number;
|
|
103
|
+
readonly maxRetries: number;
|
|
104
|
+
constructor(options?: RuntimeApiOptions);
|
|
105
|
+
toString(): string;
|
|
106
|
+
toJSON(): Record<string, unknown>;
|
|
107
|
+
evaluate(sql: string, dialect: string): Promise<Verdict>;
|
|
108
|
+
/**
|
|
109
|
+
* The dialects the server evaluates (`GET /api/v1/meta/config`), cached. `undefined`
|
|
110
|
+
* when the server cannot be asked; the evaluation request then decides.
|
|
111
|
+
*/
|
|
112
|
+
supportedDialects(): Promise<readonly string[] | undefined>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
type FailMode = 'closed' | 'open';
|
|
116
|
+
/** Where the guard reports. The SQL text is never passed to it. */
|
|
117
|
+
interface VerictoLogger {
|
|
118
|
+
info(message: string): void;
|
|
119
|
+
warn(message: string): void;
|
|
120
|
+
error(message: string): void;
|
|
121
|
+
}
|
|
122
|
+
interface VerictoOptions extends RuntimeApiOptions {
|
|
123
|
+
/** What evaluates statements. Default: a `RuntimeApiEvaluator` from the options above. */
|
|
124
|
+
evaluator?: Evaluator;
|
|
125
|
+
/**
|
|
126
|
+
* `closed` (default, or `VERICTO_FAIL_MODE`): when Vericto cannot answer, reject with
|
|
127
|
+
* `VerictoUnavailableError` and do not run the statement. `open`: run it unevaluated,
|
|
128
|
+
* emit a process warning (`VerictoFailOpenWarning`) and log it.
|
|
129
|
+
*/
|
|
130
|
+
failMode?: FailMode;
|
|
131
|
+
/** Milliseconds to reuse a verdict for the same `(sql, dialect)`. 0 (default) disables it. */
|
|
132
|
+
cacheTtlMs?: number;
|
|
133
|
+
/** Maximum cached verdicts. Default 1024. */
|
|
134
|
+
cacheSize?: number;
|
|
135
|
+
/** Called with every verdict, including `UNEVALUATED` and `BLOCKED` ones. */
|
|
136
|
+
onVerdict?: (verdict: Verdict) => void;
|
|
137
|
+
/** Default: `console` for warnings and errors, silent for info. `false` silences it. */
|
|
138
|
+
logger?: VerictoLogger | false;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Checks SQL with Vericto before it runs. Share one instance per process; the
|
|
142
|
+
* wrappers call `enforce` for every statement, and you can call it yourself around
|
|
143
|
+
* any other driver.
|
|
144
|
+
*/
|
|
145
|
+
declare class Vericto {
|
|
146
|
+
#private;
|
|
147
|
+
readonly evaluator: Evaluator;
|
|
148
|
+
readonly failMode: FailMode;
|
|
149
|
+
readonly onVerdict: ((verdict: Verdict) => void) | undefined;
|
|
150
|
+
constructor(options?: VerictoOptions);
|
|
151
|
+
/**
|
|
152
|
+
* Fail fast if the server reports that it does not evaluate `dialect`. Resolves the
|
|
153
|
+
* normalized dialect id. When the server cannot be asked, nothing is thrown here.
|
|
154
|
+
*/
|
|
155
|
+
requireDialect(dialect: string): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Evaluate `sql` and resolve the verdict, whatever it is. Does not apply the fail
|
|
158
|
+
* mode and does not reject on `BLOCKED`: use it to ask, and `enforce` to guard.
|
|
159
|
+
*/
|
|
160
|
+
check(sql: string, dialect: string): Promise<Verdict>;
|
|
161
|
+
/**
|
|
162
|
+
* Evaluate `sql` and apply the decision: reject with `VerictoBlockedError` on
|
|
163
|
+
* `BLOCKED`; log `FLAGGED`/`MONITORED`/allowed `PARSE_ERROR`; apply the fail mode
|
|
164
|
+
* when Vericto cannot answer. Run `sqlToExecute(verdict)` (the masked rewrite, if any).
|
|
165
|
+
*/
|
|
166
|
+
enforce(sql: string, dialect: string): Promise<Verdict>;
|
|
167
|
+
/** `enforce`, resolving the SQL text to execute. */
|
|
168
|
+
prepare(sql: string, dialect: string): Promise<string>;
|
|
169
|
+
/** Enforce a batch in order; a block anywhere rejects before the caller runs any of it. */
|
|
170
|
+
enforceAll(statements: readonly string[], dialect: string): Promise<Verdict[]>;
|
|
171
|
+
clearCache(): void;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { CONFIG_PATH as C, DEFAULT_API_URL as D, EVALUATE_PATH as E, RuntimeApiEvaluator as R, Vericto as V, isMasked as i, sqlToExecute as s, verdictFromResponse as v };
|
|
175
|
+
export type { Finding as F, Verdict as a, Decision as b, Evaluator as c, FailMode as d, RuntimeApiOptions as e, VerictoLogger as f, VerictoOptions as g };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Vericto decided. `UNEVALUATED` is local: Vericto could not answer and the
|
|
3
|
+
* guard runs with `failMode: 'open'`, so the statement ran without a verdict.
|
|
4
|
+
*/
|
|
5
|
+
type Decision = 'ALLOWED' | 'FLAGGED' | 'MONITORED' | 'PARSE_ERROR' | 'BLOCKED' | 'UNEVALUATED';
|
|
6
|
+
/** A rule that matched the statement. */
|
|
7
|
+
interface Finding {
|
|
8
|
+
readonly ruleCode: string;
|
|
9
|
+
readonly severity?: string;
|
|
10
|
+
readonly ruleId?: string;
|
|
11
|
+
readonly astNodePath?: string;
|
|
12
|
+
readonly suggestedFix?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Vericto's answer for one statement. */
|
|
15
|
+
interface Verdict {
|
|
16
|
+
readonly decision: Decision;
|
|
17
|
+
/** The statement as submitted. */
|
|
18
|
+
readonly sql: string;
|
|
19
|
+
readonly dialect: string;
|
|
20
|
+
readonly ruleCode?: string;
|
|
21
|
+
readonly severity?: string;
|
|
22
|
+
readonly message?: string;
|
|
23
|
+
readonly suggestedFix?: string;
|
|
24
|
+
/**
|
|
25
|
+
* When set, the statement to run **instead of** `sql`: the sensitive columns it
|
|
26
|
+
* reads come back masked (Sensitive Column Protection).
|
|
27
|
+
*/
|
|
28
|
+
readonly rewrittenQuery?: string;
|
|
29
|
+
readonly parseError?: string;
|
|
30
|
+
readonly findings: readonly Finding[];
|
|
31
|
+
readonly sensitiveColumns: readonly unknown[];
|
|
32
|
+
readonly accessDenied: readonly unknown[];
|
|
33
|
+
/** The audit-trail event id. */
|
|
34
|
+
readonly eventId?: string;
|
|
35
|
+
readonly rulesetVersion?: string;
|
|
36
|
+
readonly cached: boolean;
|
|
37
|
+
/** The response body, for fields this version does not model yet. */
|
|
38
|
+
readonly raw: Readonly<Record<string, unknown>>;
|
|
39
|
+
}
|
|
40
|
+
/** The statement the driver must run: the masked rewrite when there is one. */
|
|
41
|
+
declare function sqlToExecute(verdict: Verdict): string;
|
|
42
|
+
declare function isMasked(verdict: Verdict): boolean;
|
|
43
|
+
/** Build a verdict from a `POST /api/v1/proxy/query` response body. */
|
|
44
|
+
declare function verdictFromResponse(body: Record<string, unknown>, sql: string, dialect: string): Verdict;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Turns `(sql, dialect)` into a verdict.
|
|
48
|
+
*
|
|
49
|
+
* This release ships one implementation, `RuntimeApiEvaluator`, which asks the Vericto
|
|
50
|
+
* Runtime API. An embedded evaluator (the engine in-process, for example as WASM or a
|
|
51
|
+
* native addon with synced rules) can be added later behind the same interface
|
|
52
|
+
* without touching the wrappers.
|
|
53
|
+
*
|
|
54
|
+
* Implementations resolve a verdict for every evaluated statement (`BLOCKED`
|
|
55
|
+
* included: blocking is the guard's job), reject with `VerictoUnavailableError` when
|
|
56
|
+
* no verdict can be produced, and with `VerictoConfigError` when the request can
|
|
57
|
+
* never succeed.
|
|
58
|
+
*/
|
|
59
|
+
interface Evaluator {
|
|
60
|
+
evaluate(sql: string, dialect: string): Promise<Verdict>;
|
|
61
|
+
/** The dialects this evaluator handles, or `undefined` when it cannot tell. */
|
|
62
|
+
supportedDialects(): Promise<readonly string[] | undefined>;
|
|
63
|
+
/** Shown in error messages. */
|
|
64
|
+
readonly apiUrl?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare const DEFAULT_API_URL = "https://api.vericto.com";
|
|
68
|
+
declare const EVALUATE_PATH = "/api/v1/proxy/query";
|
|
69
|
+
declare const CONFIG_PATH = "/api/v1/meta/config";
|
|
70
|
+
type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
|
|
71
|
+
interface RuntimeApiOptions {
|
|
72
|
+
/** API key (`vtro_...`, scope `proxy:evaluate`). Default: `VERICTO_API_KEY`. */
|
|
73
|
+
apiKey?: string;
|
|
74
|
+
/** The registered database (UUID). Default: `VERICTO_DATABASE_ID`. */
|
|
75
|
+
databaseId?: string;
|
|
76
|
+
/** API base URL. Default: `VERICTO_API_URL`, then `https://api.vericto.com`. */
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
/** Per-attempt timeout in milliseconds. Default: `VERICTO_TIMEOUT` (seconds) or 5000. */
|
|
79
|
+
timeoutMs?: number;
|
|
80
|
+
/** Retries after the first attempt for network errors, timeouts, 5xx and 429 rate limits. Default 2. */
|
|
81
|
+
maxRetries?: number;
|
|
82
|
+
/** Base backoff in milliseconds (exponential, with jitter, capped at 2 s). Default 200. */
|
|
83
|
+
backoffMs?: number;
|
|
84
|
+
/** How long the server's dialect list is cached, in milliseconds. Default 10 minutes. */
|
|
85
|
+
dialectsTtlMs?: number;
|
|
86
|
+
/** A `fetch` implementation (tests, proxies). Default: the global `fetch`. */
|
|
87
|
+
fetch?: FetchLike;
|
|
88
|
+
/** Environment to read the defaults from. Default: `process.env`. */
|
|
89
|
+
env?: Record<string, string | undefined>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Evaluates statements with the Vericto Runtime API (`POST /api/v1/proxy/query`).
|
|
93
|
+
*
|
|
94
|
+
* The key is sent in the `X-API-Key` header, over HTTPS only (plain HTTP is accepted
|
|
95
|
+
* for localhost alone), and never appears in messages or `toString()`. To trust an
|
|
96
|
+
* extra CA, use Node's `NODE_EXTRA_CA_CERTS`.
|
|
97
|
+
*/
|
|
98
|
+
declare class RuntimeApiEvaluator implements Evaluator {
|
|
99
|
+
#private;
|
|
100
|
+
readonly apiUrl: string;
|
|
101
|
+
readonly databaseId: string;
|
|
102
|
+
readonly timeoutMs: number;
|
|
103
|
+
readonly maxRetries: number;
|
|
104
|
+
constructor(options?: RuntimeApiOptions);
|
|
105
|
+
toString(): string;
|
|
106
|
+
toJSON(): Record<string, unknown>;
|
|
107
|
+
evaluate(sql: string, dialect: string): Promise<Verdict>;
|
|
108
|
+
/**
|
|
109
|
+
* The dialects the server evaluates (`GET /api/v1/meta/config`), cached. `undefined`
|
|
110
|
+
* when the server cannot be asked; the evaluation request then decides.
|
|
111
|
+
*/
|
|
112
|
+
supportedDialects(): Promise<readonly string[] | undefined>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
type FailMode = 'closed' | 'open';
|
|
116
|
+
/** Where the guard reports. The SQL text is never passed to it. */
|
|
117
|
+
interface VerictoLogger {
|
|
118
|
+
info(message: string): void;
|
|
119
|
+
warn(message: string): void;
|
|
120
|
+
error(message: string): void;
|
|
121
|
+
}
|
|
122
|
+
interface VerictoOptions extends RuntimeApiOptions {
|
|
123
|
+
/** What evaluates statements. Default: a `RuntimeApiEvaluator` from the options above. */
|
|
124
|
+
evaluator?: Evaluator;
|
|
125
|
+
/**
|
|
126
|
+
* `closed` (default, or `VERICTO_FAIL_MODE`): when Vericto cannot answer, reject with
|
|
127
|
+
* `VerictoUnavailableError` and do not run the statement. `open`: run it unevaluated,
|
|
128
|
+
* emit a process warning (`VerictoFailOpenWarning`) and log it.
|
|
129
|
+
*/
|
|
130
|
+
failMode?: FailMode;
|
|
131
|
+
/** Milliseconds to reuse a verdict for the same `(sql, dialect)`. 0 (default) disables it. */
|
|
132
|
+
cacheTtlMs?: number;
|
|
133
|
+
/** Maximum cached verdicts. Default 1024. */
|
|
134
|
+
cacheSize?: number;
|
|
135
|
+
/** Called with every verdict, including `UNEVALUATED` and `BLOCKED` ones. */
|
|
136
|
+
onVerdict?: (verdict: Verdict) => void;
|
|
137
|
+
/** Default: `console` for warnings and errors, silent for info. `false` silences it. */
|
|
138
|
+
logger?: VerictoLogger | false;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Checks SQL with Vericto before it runs. Share one instance per process; the
|
|
142
|
+
* wrappers call `enforce` for every statement, and you can call it yourself around
|
|
143
|
+
* any other driver.
|
|
144
|
+
*/
|
|
145
|
+
declare class Vericto {
|
|
146
|
+
#private;
|
|
147
|
+
readonly evaluator: Evaluator;
|
|
148
|
+
readonly failMode: FailMode;
|
|
149
|
+
readonly onVerdict: ((verdict: Verdict) => void) | undefined;
|
|
150
|
+
constructor(options?: VerictoOptions);
|
|
151
|
+
/**
|
|
152
|
+
* Fail fast if the server reports that it does not evaluate `dialect`. Resolves the
|
|
153
|
+
* normalized dialect id. When the server cannot be asked, nothing is thrown here.
|
|
154
|
+
*/
|
|
155
|
+
requireDialect(dialect: string): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Evaluate `sql` and resolve the verdict, whatever it is. Does not apply the fail
|
|
158
|
+
* mode and does not reject on `BLOCKED`: use it to ask, and `enforce` to guard.
|
|
159
|
+
*/
|
|
160
|
+
check(sql: string, dialect: string): Promise<Verdict>;
|
|
161
|
+
/**
|
|
162
|
+
* Evaluate `sql` and apply the decision: reject with `VerictoBlockedError` on
|
|
163
|
+
* `BLOCKED`; log `FLAGGED`/`MONITORED`/allowed `PARSE_ERROR`; apply the fail mode
|
|
164
|
+
* when Vericto cannot answer. Run `sqlToExecute(verdict)` (the masked rewrite, if any).
|
|
165
|
+
*/
|
|
166
|
+
enforce(sql: string, dialect: string): Promise<Verdict>;
|
|
167
|
+
/** `enforce`, resolving the SQL text to execute. */
|
|
168
|
+
prepare(sql: string, dialect: string): Promise<string>;
|
|
169
|
+
/** Enforce a batch in order; a block anywhere rejects before the caller runs any of it. */
|
|
170
|
+
enforceAll(statements: readonly string[], dialect: string): Promise<Verdict[]>;
|
|
171
|
+
clearCache(): void;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { CONFIG_PATH as C, DEFAULT_API_URL as D, EVALUATE_PATH as E, RuntimeApiEvaluator as R, Vericto as V, isMasked as i, sqlToExecute as s, verdictFromResponse as v };
|
|
175
|
+
export type { Finding as F, Verdict as a, Decision as b, Evaluator as c, FailMode as d, RuntimeApiOptions as e, VerictoLogger as f, VerictoOptions as g };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkHFL7W4WC_cjs = require('./chunk-HFL7W4WC.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "CONFIG_PATH", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkHFL7W4WC_cjs.CONFIG_PATH; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "DEFAULT_API_URL", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkHFL7W4WC_cjs.DEFAULT_API_URL; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "EVALUATE_PATH", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkHFL7W4WC_cjs.EVALUATE_PATH; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "KNOWN_DIALECTS", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkHFL7W4WC_cjs.KNOWN_DIALECTS; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "RuntimeApiEvaluator", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkHFL7W4WC_cjs.RuntimeApiEvaluator; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "VERSION", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkHFL7W4WC_cjs.VERSION; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "Vericto", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkHFL7W4WC_cjs.Vericto; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "VerictoBlockedError", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkHFL7W4WC_cjs.VerictoBlockedError; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "VerictoConfigError", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkHFL7W4WC_cjs.VerictoConfigError; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "VerictoError", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkHFL7W4WC_cjs.VerictoError; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "VerictoQuotaExceededError", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return chunkHFL7W4WC_cjs.VerictoQuotaExceededError; }
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports, "VerictoUnavailableError", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return chunkHFL7W4WC_cjs.VerictoUnavailableError; }
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, "VerictoUnsupportedDialectError", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () { return chunkHFL7W4WC_cjs.VerictoUnsupportedDialectError; }
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "isMasked", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () { return chunkHFL7W4WC_cjs.isMasked; }
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "normalizeDialect", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () { return chunkHFL7W4WC_cjs.normalizeDialect; }
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(exports, "sqlToExecute", {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () { return chunkHFL7W4WC_cjs.sqlToExecute; }
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "verdictFromResponse", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function () { return chunkHFL7W4WC_cjs.verdictFromResponse; }
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=index.cjs.map
|
|
76
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { a as Verdict, F as Finding } from './guard-BVpq8ytG.cjs';
|
|
2
|
+
export { C as CONFIG_PATH, D as DEFAULT_API_URL, b as Decision, E as EVALUATE_PATH, c as Evaluator, d as FailMode, R as RuntimeApiEvaluator, e as RuntimeApiOptions, V as Vericto, f as VerictoLogger, g as VerictoOptions, i as isMasked, s as sqlToExecute, v as verdictFromResponse } from './guard-BVpq8ytG.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Dialects the Vericto engine evaluates (`sqlite` since vericto-engine 4.1.0). The
|
|
6
|
+
* wrappers still ask the server (`GET /api/v1/meta/config`) and refuse a dialect it
|
|
7
|
+
* does not list.
|
|
8
|
+
*/
|
|
9
|
+
declare const KNOWN_DIALECTS: readonly ["postgres", "mysql", "oracle", "mssql", "snowflake", "sqlite"];
|
|
10
|
+
/**
|
|
11
|
+
* Map a driver name to the Vericto dialect id. Unknown names pass through
|
|
12
|
+
* lower-cased: the server decides, and answers with a clear error.
|
|
13
|
+
*/
|
|
14
|
+
declare function normalizeDialect(name: string): string;
|
|
15
|
+
|
|
16
|
+
/** Base class of every error this package throws. */
|
|
17
|
+
declare class VerictoError extends Error {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The client is misconfigured: missing or rejected API key, bad database id, a key
|
|
22
|
+
* without the `proxy:evaluate` scope, or a malformed request. Thrown whatever the
|
|
23
|
+
* fail mode is: failing open on a revoked key would switch the firewall off silently.
|
|
24
|
+
*/
|
|
25
|
+
declare class VerictoConfigError extends VerictoError {
|
|
26
|
+
readonly status: number | undefined;
|
|
27
|
+
readonly code: string | undefined;
|
|
28
|
+
constructor(message: string, options?: {
|
|
29
|
+
status?: number;
|
|
30
|
+
code?: string;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The Vericto server does not evaluate this dialect (it is missing from
|
|
35
|
+
* `GET /api/v1/meta/config`, e.g. `sqlite` on a server older than vericto-engine
|
|
36
|
+
* 4.1.0). No SQL was executed.
|
|
37
|
+
*/
|
|
38
|
+
declare class VerictoUnsupportedDialectError extends VerictoConfigError {
|
|
39
|
+
readonly dialect: string;
|
|
40
|
+
readonly supported: readonly string[];
|
|
41
|
+
constructor(dialect: string, supported: readonly string[], apiUrl: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Vericto could not return a verdict after the configured retries. With
|
|
45
|
+
* `failMode: 'closed'` (the default) the statement is not executed and this is thrown.
|
|
46
|
+
*/
|
|
47
|
+
declare class VerictoUnavailableError extends VerictoError {
|
|
48
|
+
readonly status: number | undefined;
|
|
49
|
+
readonly code: string | undefined;
|
|
50
|
+
constructor(message: string, options?: {
|
|
51
|
+
status?: number;
|
|
52
|
+
code?: string;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** The workspace used its monthly query quota (HTTP 429 `QUOTA_EXCEEDED`). Not retried. */
|
|
56
|
+
declare class VerictoQuotaExceededError extends VerictoUnavailableError {
|
|
57
|
+
readonly resetsAt: string | undefined;
|
|
58
|
+
readonly upgradeUrl: string | undefined;
|
|
59
|
+
constructor(message: string, options?: {
|
|
60
|
+
resetsAt?: string;
|
|
61
|
+
upgradeUrl?: string;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** Vericto blocked the statement. It was not executed. */
|
|
65
|
+
declare class VerictoBlockedError extends VerictoError {
|
|
66
|
+
readonly verdict: Verdict;
|
|
67
|
+
readonly sql: string;
|
|
68
|
+
constructor(verdict: Verdict, sql: string);
|
|
69
|
+
get findings(): readonly Finding[];
|
|
70
|
+
get suggestedFix(): string | undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The package version (kept in sync with package.json by a test). */
|
|
74
|
+
declare const VERSION = "0.2.0";
|
|
75
|
+
|
|
76
|
+
export { Finding, KNOWN_DIALECTS, VERSION, Verdict, VerictoBlockedError, VerictoConfigError, VerictoError, VerictoQuotaExceededError, VerictoUnavailableError, VerictoUnsupportedDialectError, normalizeDialect };
|