# Code Deb SDK Core

**Verified registry:** `@codedeb/sdk-core@0.2.1` was confirmed publicly (version metadata, latest dist-tag and tarball).

**Published:** [@codedeb/sdk-core@0.2.0](https://www.npmjs.com/package/@codedeb/sdk-core) · **Runtime:** ES modules, Node.js 20+ / modern browsers · **Types:** bundled TypeScript declarations.

A small set of defensive application and SDK primitives: Unicode-safe input validation, HTTPS URL checks, XML/JSON-LD escaping, locale handling, tenant idempotency keys and bounded HTTP-client utilities.

## Install

```bash
npm install @codedeb/sdk-core
```

Use only the documented public exports. The package does not include a hosted API, login service or privileged tenant authorization.

## Validate input and serialize content

```ts
import {boundedText,absoluteHttpUrl,assertLocale,safeJsonLd,xmlEscape}
  from '@codedeb/sdk-core';

const displayName=boundedText('  नमस्ते  ','displayName',100);
const origin=absoluteHttpUrl('https://example.com');
const locale=assertLocale('ne-NP');
const ld=safeJsonLd({'@context':'https://schema.org',name:displayName});
const safeXml=xmlEscape(displayName);
console.log(displayName,origin.origin,locale,ld,safeXml);
```

`boundedText` normalizes Unicode to NFC and rejects empty, oversized and control-character-containing values. `absoluteHttpUrl` rejects unsafe protocols, URL credentials and fragments. These are application-side validation utilities, not a replacement for input authorization, CSP or output context safety.

## Tenant and HTTP helpers

```ts
import {idempotencyKey} from '@codedeb/sdk-core/tenant';
import {createSdkHttpClient} from '@codedeb/sdk-core/client';

const key=idempotencyKey('order-2026-001');
console.log(key,typeof createSdkHttpClient);
```

The client wrapper is for caller-configured authenticated requests. Your server must verify tenant membership, correctly scope credentials, enforce rate limits and persist idempotency outcomes atomically. Never bundle application secrets in client-side code.

## Public entrypoints

| Import | Purpose |
| --- | --- |
| `@codedeb/sdk-core` | Input invariants, locale checks and safe text serialization |
| `@codedeb/sdk-core/client` | HTTP client helper and bounded retry behavior |
| `@codedeb/sdk-core/tenant` | Tenant-safe idempotency identifiers |

## Compatibility and production

The package is ESM-only and its first release requires Node.js 20+ for Node deployments. No database, OAuth grant or hosted service is supplied. Test response behavior, authentication and multi-tenant isolation in the consuming application.

## Release history

- **0.2.0 — 20 November 2026:** First independently packaged public npm version. Compiled JavaScript and TypeScript declaration exports were tested in an isolated consumer.

## License and links

Free for noncommercial use under **Code Deb SDK Noncommercial License 1.0** in the npm tarball. Commercial use requires a separate agreement; this is not an OSI open-source license.

[API reference](/docs/sdk/sdk-core) · [Engineering guide](/blog/sdk-core-secure-typescript-primitives) · [All SDKs](/docs/sdk) · [npm package](https://www.npmjs.com/package/@codedeb/sdk-core)

## Production implementation walkthrough

1. Validate untrusted strings, URLs and locales before SDK requests.
2. Keep tenant authorization server-side; an idempotency key does not grant access.
3. Serialize JSON-LD/XML with escaping helpers instead of string concatenation.
4. Retry only bounded, idempotent requests and propagate typed failures.

## Reproducible installation and compatibility

```bash
npm view @codedeb/sdk-core@0.2.1 version
npm install @codedeb/sdk-core@0.2.1
```

Pin the exact version in the application lockfile; review its exported ESM subpaths and bundled TypeScript declarations. A new package version does not retroactively update older immutable tarballs.

## Integration acceptance checklist

- Validate boundary inputs, invalid payloads and every caller-provided adapter before connecting customer data.
- Type-check the actual package from a clean test application, not only from this monorepo's source paths.
- Exercise authorization failures, missing configuration and relevant concurrency or retry paths.
- Keep credential and sensitive data out of logs; store only necessary operational evidence.

## Troubleshooting and version policy

**Module not found:** Check the exact import subpath and package version in `node_modules` and the lockfile. **Unexpected result:** Review the required application-owned credentials and adapters. **npm 404:** Verify the requested immutable version using the public registry; do not mistake a local tarball for a published release.

## Related integration guides

See [webhook kit](/docs/sdk/webhook-kit) and [log redact](/docs/sdk/log-redact) for complementary capabilities. Use the [SDK directory](/docs/sdk) and [Developer resources](/docs/resources) for API references and engineering guides.
