# @x12i/credorix-client

> Client SDK for Credorix token leases and authenticated requests.

Latest version **1.5.0** (published 2026-08-12) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @x12i/credorix-client
pnpm add @x12i/credorix-client
yarn add @x12i/credorix-client
bun add @x12i/credorix-client
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2026-08-12 |
| First published | 2026-07-18 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 336.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | x12i |

## Links

- npm: https://www.npmjs.com/package/@x12i/credorix-client
- npm.io page: https://npm.io/package/@x12i/credorix-client

## Dependencies (1)

- [@x12i/credorix-core](https://npm.io/package/@x12i/credorix-core.md) 1.5.0

## Recent versions

- 1.5.0 (latest) — 2026-08-12
- 1.4.0 — 2026-08-11
- 1.3.1 — 2026-07-30
- 1.3.0 — 2026-07-30
- 1.2.0 — 2026-07-18
- 0.2.0 — 2026-07-18
- 0.1.0 — 2026-07-18

## README

# @x12i/credorix-client

The Credorix SDK for token leases, request brokering, local auth injection, a single safe retry after a `401`, and **Memorix connector-framework ports** (`createGovernedCredentialProvider` / `createGovernedHttpPort`).

## Semver policy (connector capabilities)

- Additive methods and non-breaking field additions: **minor**
- Adding, removing, or renaming `CredentialCapability` **kinds**: **major**
- Docs-only pins (`@x12i/credorix-docs`) are not a substitute for this runtime package

## Classic lease / broker client

```ts
import { createCredorixClient } from "@x12i/credorix-client";

const credorix = createCredorixClient({
  serviceUrl: "http://credorix:9202",
  callerId: "service:risk-worker",
  callerToken: process.env.CREDORIX_CALLER_TOKEN!,
});

const response = await credorix.fetch("https://api.example.com/data", {
  method: "POST",
  authRef: "vendor-api",
  body: { query: "example" },
});
```

## Worker env helpers

Workers that read `CREDORIX_BASE_URL` / `CREDORIX_CALLER_ID` / `CREDORIX_CALLER_TOKEN` can use the env-wired helpers (also re-exported from `@x12i/credorix`):

```ts
import {
  createWorkerCredorixClient,
  leaseForAuthRef,
  fetchSanitizedProfile,
  loadEnvFile,
} from "@x12i/credorix-client";

loadEnvFile(); // optional: walk up from cwd for nearest .env

const client = createWorkerCredorixClient();
const lease = await leaseForAuthRef("vendor-api");
const profile = await fetchSanitizedProfile("vendor-api");

// Simulation: set CREDORIX_USE_STUBS=true and inject fetch (no bundled simulator)
const sim = createWorkerCredorixClient(
  { CREDORIX_USE_STUBS: "true" },
  { fetchImplementation: mySimulatedFetch },
);
```

Also: transport-lease wrappers, `isCredorixConfigured`, material extractors (`bearerAccessToken`, `apiKeyValue`, `basicParts`), and `baseUrlFromProfile`.

## Connector host ports (CRX-CF / `memorix-connector/1`)

Replace Memorix local stubs with Credorix ports — connectors receive purpose-bound capabilities, never unbounded secret bags:

```ts
import {
  createGovernedCredentialProvider,
  createGovernedHttpPort,
} from "@x12i/credorix-client";

const credentials = createGovernedCredentialProvider({
  serviceUrl: "http://credorix:9202",
  callerId: "service:memorix-host",
  callerToken: process.env.CREDORIX_CALLER_TOKEN!,
});

const delegation = await credentials.mintDelegation({
  organizationId: "org-1",
  sourceId: "src-jira",
  connectorId: "jira-cloud",
  connectorVersion: "1.0.0",
  authRef: "jira-api",
  purposes: ["provider-http"],
  allowedOrigins: ["https://api.atlassian.com"],
  correlation: { runId: "run-1", invocationId: "inv-1" },
});

const capability = await credentials.resolve(delegation.delegationId, {
  purpose: "provider-http",
});

const http = createGovernedHttpPort({
  serviceUrl: "http://credorix:9202",
  callerId: "service:memorix-host",
  callerToken: process.env.CREDORIX_CALLER_TOKEN!,
  delegationId: delegation.delegationId,
});

if (capability.kind === "brokered-fetch") {
  const result = await http.fetch({
    url: "https://api.atlassian.com/ex/jira/…",
    method: "GET",
  });
}

await credentials.invalidate(delegation.delegationId, "run_canceled");
```

---
_Source: https://npm.io/package/@x12i/credorix-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
