# @or-sdk/base

> Shared HTTP client for OneReach SDK packages

Latest version **0.45.2** (published 2026-09-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @or-sdk/base
pnpm add @or-sdk/base
yarn add @or-sdk/base
bun add @or-sdk/base
```

## 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; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.45.2 |
| Published | 2026-09-25 |
| First published | 2021-10-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 157.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | onereach.admin, user.npm |

## Links

- npm: https://www.npmjs.com/package/@or-sdk/base
- npm.io page: https://npm.io/package/@or-sdk/base

## Dependencies (2)

- [qs](https://npm.io/package/qs.md) ^6.15.3
- [axios](https://npm.io/package/axios.md) ^1.18.1

## Recent versions

- 0.45.2 (latest) — 2026-09-25
- 0.45.2-beta.4380.0 (beta) — 2026-09-25
- 0.45.1 — 2026-09-21
- 0.45.1-beta.4364.0 — 2026-09-21
- 0.45.1-beta.4362.0 — 2026-09-21
- 0.45.0 — 2026-08-05
- 0.44.8-beta.4286.0 — 2026-08-05
- 0.44.8-beta.4283.0 — 2026-08-05
- 0.44.8-beta.4282.0 — 2026-08-05
- 0.44.8-beta.4273.0 — 2026-08-05
- 0.44.8-beta.4272.0 — 2026-08-05
- 0.44.8-beta.4268.0 — 2026-08-05
- 0.44.7 — 2026-08-04
- 0.44.3 — 2026-07-01
- 0.44.3-beta.4186.0 — 2026-07-01
- … 393 more at https://npm.io/package/@or-sdk/base/versions

## README

# `@or-sdk/base`

Shared HTTP transport for OneReach SDK packages. It has no `SERVICE_KEY`; subclasses provide the service key and API methods.

## When to use

- Extend `Base` when building an `@or-sdk/*` client for a OneReach service.

## When not to use

- For application calls to an existing service, use that service's dedicated SDK instead of extending `Base`.

## Installation

```bash
npm install @or-sdk/base
```

## Usage

Provide a token string or getter and a direct service URL when known. Use a discovery URL only when the service URL must be resolved.

```typescript
import { Base } from '@or-sdk/base';

class ExampleClient extends Base {
  constructor(token: string, serviceUrl: string) {
    super({ token, serviceUrl, serviceKey: 'example' });
  }

  getItems() {
    return this.callApiV2({ route: '/items', method: 'GET' });
  }
}

const client = new ExampleClient(token, 'https://example.onereach.ai');
await client.getItems();
```

Alternatively, pass `discoveryUrl` in place of `serviceUrl` to resolve the service on first request.

## Critical pitfalls

- In Node.js, redirects are followed only to HTTPS on the exact same hostname, with a limit of five hops. HTTP-to-HTTPS upgrades and same-host HTTPS redirects work; HTTP targets, other hostnames, and URLs containing credentials are rejected. A rejected redirect fails the request. Resolve the correct service URL rather than relying on cross-host redirects.
- An HTTP starting URL still sends the first request, including its Authorization header, over plaintext before the upgrade. Use an HTTPS starting URL for token-bearing requests.
- This transport rule applies to requests made through `Base`. A subclass that uses another HTTP client must enforce its own redirect policy.

## Method map

| Method | Purpose |
|--------|---------|
| `init()` | Resolve and prepare the service URL. |
| `callApiV2(params)` | Send an authenticated request from a subclass. |
| `callApi(params)` | Legacy authenticated request method; deprecated. |

See `src/Base.ts` and `src/types.ts` for the complete protected API and configuration types.

## Auth

`token` is a string or getter returning the Authorization header value. Treat service URLs and discovery responses as security-sensitive because the SDK sends this token to the resolved destination.

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