open-index/open-npm huggingface dataset:
npm package: @sapiom/axios
Description: Axios integration for Sapiom SDK
Author: Sapiom
Latest version: 0.5.0

# @sapiom/axios

[![npm version](https://badge.fury.io/js/%40sapiom%2Faxios.svg)](https://www.npmjs.com/package/@sapiom/axios)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> ⚠️ **Beta Status:** Currently in v0.x. API may change before v1.0.0. Production-ready and actively maintained.

Axios integration for Sapiom SDK providing automatic payment handling (402 errors) and pre-emptive authorization.

## Installation

```bash
npm install @sapiom/axios axios
```

## Quick Start

```typescript
import axios from 'axios';
import { withSapiom } from '@sapiom/axios';

const client = withSapiom(axios.create({
  baseURL: 'https://api.example.com'
}), {
  apiKey: process.env.SAPIOM_API_KEY
});

// Automatically handles 402 payment flows and authorization
const response = await client.get('/premium-endpoint');
```

## Features

- ✅ Drop-in wrapper for Axios instances
- ✅ Automatic 402 payment handling
- ✅ Pre-emptive authorization
- ✅ Full TypeScript support
- ✅ Access to underlying SapiomClient
- ✅ Environment variable configuration

## Configuration

```typescript
import { withSapiom } from '@sapiom/axios';

const client = withSapiom(axiosInstance, {
  // Required (or use SAPIOM_API_KEY environment variable)
  apiKey: 'sk_...',

  // Optional - Control
  enabled: true,              // Enable Sapiom handling (default: true)
  failureMode: 'open',        // 'open' | 'closed' (default: 'open')
                              // 'open': Allow requests if Sapiom fails (prioritizes availability)
                              // 'closed': Block requests if Sapiom fails (prioritizes security)

  // Optional - Default metadata (applied to all requests)
  agentName: 'my-agent',      // Agent identifier
  agentId: 'agent-123',       // Agent UUID or numeric ID
  serviceName: 'my-service',  // Service name for transactions
  traceId: 'trace-xyz',       // Internal trace UUID
  traceExternalId: 'ext-456', // External trace identifier
});
```

### Per-Request Overrides

Override configuration for individual requests using the `__sapiom` property:

```typescript
// Disable Sapiom for a specific request
await client.get('/public-endpoint', {
  __sapiom: { enabled: false }
});

// Override metadata for a specific request
await client.post('/api/resource', data, {
  __sapiom: {
    serviceName: 'different-service',
    actionName: 'custom-action',
    traceExternalId: 'ext-789'
  }
});
```

## Environment Variables

Automatically reads from environment:
- `SAPIOM_API_KEY` (required)
- `SAPIOM_BASE_URL` or `SAPIOM_API_URL` (optional)
- `SAPIOM_TIMEOUT` (optional, in milliseconds)

## License

MIT © [Sapiom](../../LICENSE)

## Links

- [Documentation](https://docs.sapiom.ai)
- [GitHub](https://github.com/sapiom/sapiom-js)
- [NPM](https://www.npmjs.com/package/@sapiom/axios)
npm package: @sapiom/fetch
Description: Fetch API integration for Sapiom SDK
Author: Sapiom
Latest version: 0.5.0

# @sapiom/fetch

[![npm version](https://badge.fury.io/js/%40sapiom%2Ffetch.svg)](https://www.npmjs.com/package/@sapiom/fetch)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> ⚠️ **Beta Status:** Currently in v0.x. API may change before v1.0.0. Production-ready and actively maintained.

Fetch API integration for Sapiom SDK providing automatic payment handling (402 errors) and pre-emptive authorization.

## Installation

```bash
npm install @sapiom/fetch
```

**Note:** Requires Node.js 18+ (native fetch).

## Quick Start

```typescript
import { createFetch } from '@sapiom/fetch';

const fetch = createFetch({
  apiKey: process.env.SAPIOM_API_KEY
});

// Drop-in replacement for native fetch
const response = await fetch('https://api.example.com/data');
const data = await response.json();
```

## Features

- ✅ Drop-in replacement for native fetch
- ✅ Automatic 402 payment handling
- ✅ Pre-emptive authorization
- ✅ Full TypeScript support
- ✅ Uses native Fetch API (no additional HTTP client needed)
- ✅ Environment variable configuration

## Configuration

```typescript
import { createFetch } from '@sapiom/fetch';

const fetch = createFetch({
  // Required (or use SAPIOM_API_KEY environment variable)
  apiKey: 'sk_...',

  // Optional - Control
  enabled: true,              // Enable Sapiom handling (default: true)
  failureMode: 'open',        // 'open' | 'closed' (default: 'open')
                              // 'open': Allow requests if Sapiom fails (prioritizes availability)
                              // 'closed': Block requests if Sapiom fails (prioritizes security)

  // Optional - Default metadata (applied to all requests)
  agentName: 'my-agent',      // Agent identifier
  agentId: 'agent-123',       // Agent UUID or numeric ID
  serviceName: 'my-service',  // Service name for transactions
  traceId: 'trace-xyz',       // Internal trace UUID
  traceExternalId: 'ext-456', // External trace identifier
});
```

### Per-Request Overrides

Override configuration for individual requests using the `__sapiom` property:

```typescript
// Disable Sapiom for a specific request
const publicRequest = new Request('/api/public');
(publicRequest as any).__sapiom = { enabled: false };
await fetch(publicRequest);

// Override metadata for a specific request
const request = new Request('/api/resource', { method: 'POST' });
(request as any).__sapiom = {
  serviceName: 'different-service',
  actionName: 'custom-action',
  traceExternalId: 'ext-789'
};
await fetch(request);
```

## Environment Variables

Automatically reads from environment:
- `SAPIOM_API_KEY` (required)
- `SAPIOM_BASE_URL` or `SAPIOM_API_URL` (optional)
- `SAPIOM_TIMEOUT` (optional, in milliseconds)

## License

MIT © [Sapiom](../../LICENSE)

## Links

- [Documentation](https://docs.sapiom.ai)
- [GitHub](https://github.com/sapiom/sapiom-js)
- [NPM](https://www.npmjs.com/package/@sapiom/fetch)
npm package: @sapiom/langchain
Description: LangChain v1.x integration for Sapiom SDK
Author: Sapiom
Latest version: 0.4.0

# @sapiom/langchain

> **LangChain v1.x Integration:** For LangChain v0.3.x, use [`@sapiom/langchain-classic`](../langchain-classic/README.md) instead.

LangChain v1.x integration for Sapiom SDK.

## Installation

```bash
npm install @sapiom/langchain langchain
```

> **Note:** The `createAgent` API shown below is part of LangChain v1.x.

## Quick Start

```typescript
import { createAgent } from "langchain";
import { createSapiomMiddleware } from "@sapiom/langchain";

const agent = createAgent({
  model: "gpt-4",
  tools: [getWeather, sendEmail],
  middleware: [
    createSapiomMiddleware({
      apiKey: process.env.SAPIOM_API_KEY,
    }),
  ],
});

// All model and tool calls are automatically tracked!
const result = await agent.invoke({
  messages: [{ role: "user", content: "What's the weather in Tokyo?" }],
});
```

## Configuration

```typescript
createSapiomMiddleware({
  // Required (or use SAPIOM_API_KEY env var)
  apiKey: "sk-...",

  // Control behavior
  enabled: true,           // Enable/disable tracking
  failureMode: "open",     // 'open' (graceful) | 'closed' (strict)

  // Default trace/agent info
  traceId: "my-workflow",  // Groups related transactions
  agentId: "AG-001",       // Tag with existing agent
  agentName: "my-agent",   // Find-or-create agent by name
});
```

## Per-Invocation Overrides

```typescript
await agent.invoke(
  { messages: [...] },
  {
    context: {
      sapiomTraceId: "conversation-456",
      sapiomAgentId: "AG-002",
    },
  }
);
```

## Failure Modes

| Mode | Behavior |
|------|----------|
| `open` (default) | Log errors, continue without tracking |
| `closed` | Throw errors, block operations |

Authorization denials always throw regardless of failure mode.

## What Gets Tracked

- **Agent lifecycle**: Start/end transactions
- **Model calls**: Token estimation, actual usage, tool calls
- **Tool calls**: Pre-authorization, payment retry (x402-mcp)

## LangChain v0.x

For LangChain v0.x (< 1.0.0), use `@sapiom/langchain-classic`:

```bash
npm install @sapiom/langchain-classic
```

See [@sapiom/langchain-classic](../langchain-classic) for documentation.

## License

MIT © [Sapiom](../../LICENSE)

## Links

- [Documentation](https://docs.sapiom.ai)
- [GitHub](https://github.com/sapiom/sapiom-js)
- [NPM](https://www.npmjs.com/package/@sapiom/langchain)
npm package: @sapiom/node-http
Description: Node.js HTTP/HTTPS integration for Sapiom SDK
Author: Sapiom
Latest version: 0.4.0

# @sapiom/node-http

[![npm version](https://badge.fury.io/js/%40sapiom%2Fnode-http.svg)](https://www.npmjs.com/package/@sapiom/node-http)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

> ⚠️ **Beta Status:** Currently in v0.x. API may change before v1.0.0. Production-ready and actively maintained.

Node.js HTTP/HTTPS integration for Sapiom SDK providing automatic payment handling (402 errors) and pre-emptive authorization.

## Installation

```bash
npm install @sapiom/node-http
```

## Quick Start

```typescript
import { createClient } from '@sapiom/node-http';

const client = createClient({
  apiKey: process.env.SAPIOM_API_KEY
});

const response = await client.request({
  method: 'GET',
  url: 'https://api.example.com/data',
  headers: {}
});
```

## Features

- ✅ Native Node.js http/https support
- ✅ Automatic 402 payment handling
- ✅ Pre-emptive authorization
- ✅ Full TypeScript support
- ✅ Uses Node.js standard library (no additional HTTP client needed)
- ✅ Environment variable configuration

## Configuration

```typescript
import { createClient } from '@sapiom/node-http';

const client = createClient({
  // Required (or use SAPIOM_API_KEY environment variable)
  apiKey: 'sk_...',

  // Optional - Control
  enabled: true,              // Enable Sapiom handling (default: true)
  failureMode: 'open',        // 'open' | 'closed' (default: 'open')
                              // 'open': Allow requests if Sapiom fails (prioritizes availability)
                              // 'closed': Block requests if Sapiom fails (prioritizes security)

  // Optional - Default metadata (applied to all requests)
  agentName: 'my-agent',      // Agent identifier
  agentId: 'agent-123',       // Agent UUID or numeric ID
  serviceName: 'my-service',  // Service name for transactions
  traceId: 'trace-xyz',       // Internal trace UUID
  traceExternalId: 'ext-456', // External trace identifier
});
```

### Per-Request Overrides

Override configuration for individual requests using the `__sapiom` property:

```typescript
// Disable Sapiom for a specific request
await client.request({
  method: 'GET',
  url: 'https://api.example.com/public',
  headers: {},
  __sapiom: { enabled: false }
});

// Override metadata for a specific request
await client.request({
  method: 'POST',
  url: 'https://api.example.com/resource',
  headers: { 'Content-Type': 'application/json' },
  body: { data: 'test' },
  __sapiom: {
    serviceName: 'different-service',
    actionName: 'custom-action',
    traceExternalId: 'ext-789'
  }
});
```

## Environment Variables

Automatically reads from environment:
- `SAPIOM_API_KEY` (required)
- `SAPIOM_BASE_URL` or `SAPIOM_API_URL` (optional)
- `SAPIOM_TIMEOUT` (optional, in milliseconds)

## License

MIT © [Sapiom](../../LICENSE)

## Links

- [Documentation](https://docs.sapiom.ai)
- [GitHub](https://github.com/sapiom/sapiom-js)
- [NPM](https://www.npmjs.com/package/@sapiom/node-http)
npm package: @sapioweb/authentication
Description: `npm i @sapioweb/authentication --save`
Author: Andreas Beasley
Latest version: 1.2.4

## Installation

`npm i @sapioweb/authentication --save`

Basic authentication for a very simple use of logging in and registering users with their email and password. Currently there is no expansion of schemas but there are a few required validation checks baked in which are listed below.  

validateEmail()
```text
Must be an email format
```
uniqueEmail()
```text
Email will be required to be unique
```
validatePassword()
 ```
Must contain at least 1 lowercase alphabetical character.
Must contain at least 1 uppercase alphabetical character.
Must contain at least 1 numeric character.
Must contain at least one special character, but we are escaping reserved RegEx characters to avoid conflict.
Must be eight characters or longer.
```

### Setup
Wherever you may be including you environment variables, you will need to add `JWT_SECRET` with any random value you prefer.

First things first, be sure you have a connection to mongoDB already established as well as body parser to handle incoming json payloads. All other configuations you may think of are to your liking.
```typescript
config();

app.use(json());

connect(<string>process.env.CONNECTION_STRING, {
  useNewUrlParser: true,
  useUnifiedTopology: true
}).then(() => console.log('DB Connected'))
  .catch(() => console.log('Error connecting DB'));

app.use('', router);

app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  if (res.headersSent) {
    return next(err)
  }

  return res.json({
    success: false,
    message: err.message,
    payload: req.body
  })
});

app.listen(3000, () => console.log('http://localhost:3000'));

```

You may name your routes however you may please, however be mindful of the usage of the two authentication methods for logging in and registering.
```typescript
const router = Router();

// Mount routes
router.post('/login', login);
router.post('/register', register);

export { router }
```

Following object displays the only allowed keys in order for requests to work.
```typescript
interface IUser {
  email: string;
  password: string;
}
```