/** * FedPulse SDK — main client class. * * Instantiate this class with your API key to access all FedPulse * data resources and the webhook verification utility. * * @example * ```ts * import { FedPulse } from '@fedpulse/sdk'; * * const client = new FedPulse({ apiKey: process.env.FEDPULSE_API_KEY! }); * * // Search contracts * const { data } = await client.opportunities.list({ q: 'cloud', naics: '541512' }); * * // Compliance check * const { data: status } = await client.exclusions.check({ entities: [{ uei: 'ABCDEF123456' }] }); * * // Verify an incoming webhook * const payload = FedPulse.verifyWebhook({ rawBody, signatureHeader, timestampHeader, secret }); * ``` */ import { HttpClient } from './http.js'; import type { HttpClientOptions } from './http.js'; import { OpportunitiesResource } from './resources/opportunities.js'; import { ExclusionsResource } from './resources/exclusions.js'; import { EntitiesResource } from './resources/entities.js'; import { IntelligenceResource } from './resources/intelligence.js'; import { AssistanceResource } from './resources/assistance.js'; import { AnalyticsResource } from './resources/analytics.js'; import { WebhooksResource } from './resources/webhooks.js'; import { extractWebhookHeaders, WebhookVerificationError } from './webhooks-verify.js'; import type { VerifyWebhookInput } from './webhooks-verify.js'; import type { WebhookPayload } from './types/webhooks.js'; import type { RateLimitInfo } from './types/common.js'; export type { HttpClientOptions }; /** * Configuration options for the FedPulse SDK client. */ export interface FedPulseOptions extends Omit { /** * Your FedPulse API key. * Generate one at https://app.fedpulse.dev/dashboard. * * **Security:** Never hardcode this value. Use environment variables: * ```ts * const client = new FedPulse({ apiKey: process.env.FEDPULSE_API_KEY! }); * ``` */ apiKey: string; } /** * The FedPulse SDK client. * * All API interactions go through the resource properties on this class. * The static `verifyWebhook` method can be used independently of a client instance. */ export declare class FedPulse { /** Low-level HTTP client (exposed for advanced usage only). */ readonly http: HttpClient; /** Federal contract opportunities (/v1/opportunities). */ readonly opportunities: OpportunitiesResource; /** SAM.gov exclusions and bulk compliance checks (/v1/exclusions). */ readonly exclusions: ExclusionsResource; /** SAM.gov registered entities / vendors (/v1/entities). */ readonly entities: EntitiesResource; /** 360° entity intelligence and market analysis (/v1/intelligence). */ readonly intelligence: IntelligenceResource; /** Federal assistance listings / CFDA programs (/v1/assistance). */ readonly assistance: AssistanceResource; /** Per-user API usage analytics (/v1/analytics). */ readonly analytics: AnalyticsResource; /** Webhook subscription management (/v1/webhooks). */ readonly webhooks: WebhooksResource; constructor(options: FedPulseOptions); /** * Most recent rate-limit info observed from API responses. * * Updated after every API call. Useful for monitoring your rate-limit usage. * * @example * ```ts * await client.opportunities.list({ limit: 25 }); * console.log('Remaining requests:', client.rateLimit?.remaining); * ``` */ get rateLimit(): RateLimitInfo | null; /** * Clear the in-memory response cache. * * Useful after writes that may invalidate cached GET responses. */ clearCache(): void; /** * Verify an incoming FedPulse webhook delivery. * * Validates the HMAC-SHA256 signature, checks the timestamp against replay * attacks, and returns the parsed payload on success. * * **IMPORTANT:** Pass the raw request body bytes — do not parse to JSON first. * * @param input Headers, raw body, and signing secret. * @returns Parsed, verified webhook payload. * @throws {WebhookVerificationError} If signature/timestamp is invalid. * * @example * ```ts * // Express.js with `express.raw({ type: 'application/json' })`: * const payload = FedPulse.verifyWebhook<{ noticeId: string }>({ * rawBody: req.body, // Buffer from express.raw() * signatureHeader: req.headers['x-fedpulse-signature'] as string, * timestampHeader: req.headers['x-fedpulse-timestamp'] as string, * secret: process.env.FEDPULSE_WEBHOOK_SECRET!, * }); * console.log(payload.event, payload.data.noticeId); * ``` */ static verifyWebhook(input: VerifyWebhookInput): WebhookPayload; /** * Extract FedPulse webhook headers from a request headers object. * * Handles case-insensitive lookup across Express, Fastify, Next.js, etc. * * @param headers Headers object (plain object or `Headers` instance). * @returns Signature header, timestamp header, event type, and delivery ID. * * @example * ```ts * const { signatureHeader, timestampHeader } = FedPulse.extractWebhookHeaders(req.headers); * const payload = FedPulse.verifyWebhook({ rawBody, signatureHeader, timestampHeader, secret }); * ``` */ static extractWebhookHeaders(headers: Record | Headers): ReturnType; } export { WebhookVerificationError }; //# sourceMappingURL=client.d.ts.map