Node.js SDK for Poland
@corp-merch/sdk — TypeScript-first, zero dependencies, works on Node 18+, Bun, Deno, Vercel and AWS Lambda.
Install & init
npm install @corp-merch/sdk. Initialise: const cm = new CorpMerch({ apiKey: process.env.CM_KEY, country: 'Poland', env: 'production' }). The client autoloads VAT 23% and routes invoices through KSeF; Warszawa hub is default for fulfilment.
Quickstart — submit an order
const order = await cm.orders.create({ idempotencyKey: crypto.randomUUID(), buyer: { vatId: 'EU…' }, lines: [{ sku: 'TSH-001', qty: 200 }], promisedDate: '2026-07-01' }); console.log(order.id, order.estimatedIvaAmountCents). Returns a fully typed Order with discriminated-union status. Errors thrown as ValidationError / RateLimitError etc.
Webhook verification
In an Express/Fastify route: const event = cm.webhooks.constructEvent(rawBody, req.headers['x-corp-signature'], process.env.CM_WEBHOOK_SECRET); switch (event.type) { case 'invoice.issued': … }. Throws SignatureVerificationError on mismatch or stale timestamp (>5 min).
FAQ
ESM or CommonJS?
Both — dual package. ESM preferred (we ship .mjs + .d.ts), CommonJS via require() works seamlessly via package.json exports.
Does it work with Bun and Deno?
Yes — tested in CI on Bun 1.x and Deno 1.x with the same test suite as Node. Use the npm: specifier in Deno or just import in Bun.
How are retries configured?
Default 3 retries on 5xx, 429 and network errors with backoff. Override via new CorpMerch({ retries: 5, retryBackoffMs: 200 }).
Is there a streaming catalog method?
Yes — cm.catalog.list({ country: 'Poland' }) returns an AsyncIterator; for await (const item of …) iterates over all pages automatically (cursor handling internal).
Source available?
MIT-licensed on GitHub: github.com/corp-merch/sdk-js. PRs welcome; CLA required for non-trivial contributions.