UNPKG

vulncheck-sdk

Version:

A comprehensive TypeScript/JavaScript SDK for the VulnCheck API - vulnerability intelligence platform with enriched CVE data, threat intelligence, and security tooling

34 lines 1.1 kB
export function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } export function isValidCVE(cve) { return /^CVE-\d{4}-\d{4,}$/.test(cve); } export function isValidCPE(cpe) { return /^cpe:2\.3:[aho*]:.+/.test(cpe); } export function isValidPURL(purl) { return /^pkg:.+/.test(purl); } export function buildQueryString(params) { const filteredParams = {}; Object.entries(params) .filter(([, value]) => value !== undefined && value !== null) .forEach(([key, value]) => { filteredParams[key] = String(value); }); if (Object.keys(filteredParams).length === 0) { return ''; } const searchParams = new URLSearchParams(filteredParams); return `?${searchParams.toString()}`; } export function validateConfig(config) { if (!config.apiKey || typeof config.apiKey !== 'string') { throw new Error('API key is required and must be a string'); } if (config.baseURL && typeof config.baseURL !== 'string') { throw new Error('Base URL must be a string'); } } //# sourceMappingURL=index.js.map