# @idp.global/interfaces

Shared TypeScript contracts for the `idp.global` backend, browser client, CLI, and frontend.

Use this package when you want typed request/response payloads and shared data models for users, sessions, organizations, apps, billing, passport devices, alerts, and OIDC.

## Issue Reporting and Security

For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.

## Install

```bash
pnpm add @idp.global/interfaces
```

## Quick Start

```ts
import { data, dto, request, tags } from '@idp.global/interfaces';
import * as devidp from '@idp.global/interfaces/devidp';

const loginRequest: request.IReq_LoginWithEmailOrUsernameAndPassword['request'] = {
  username: 'user@example.com',
  password: 'secret',
};

const organization: data.IOrganization = {
  id: 'org_1',
  data: {
    name: 'Acme',
    slug: 'acme',
    status: 'active',
    billingPlanId: 'plan_free',
    roleIds: [],
  },
};
```

## Exports

### `data`

The `data` export includes types for:

- users
- organizations
- roles
- JWT payloads
- login sessions
- devices
- finite activity classifications
- alerts and alert rules
- apps and app connections
- billing plans and Paddle checkout data
- passport devices, challenges, and nonces
- abuse windows
- OIDC data structures
- invitations

### `request`

The `request` export includes typed request contracts for:

- login, logout, refresh, password reset, and device attachment
- registration flow requests
- user and session queries
- organization CRUD-style requests
- invitations and membership changes
- app and admin actions
- billing and JWT validation-keyset support
- alert and passport approval flows
- OIDC authorization preparation and completion

### `dto`

The `dto` export includes normalized transfer objects for activity, alerts, apps, billing, invitations, MFA, organizations, passport, and users. Activity responses use the discriminated `TActivityEventDto` union, which contains only finite classifications and allowlisted per-action facts. Persistence identities, actor and target identities, free text, network data, integrity fields, and sink delivery state are backend-private.

### `tags`

Shared tag exports live under `tags/`.

### `devidp`

The Node.js-only `@idp.global/interfaces/devidp` subpath owns the strict local
Development IdP manifest/result shapes, canonical validation and fingerprint,
fixed hostname/persona inventories, deterministic namespace derivations, and
the closed `platform-personas-v1` authority profile.
It deliberately excludes provisioning, credentials, persisted fixture
receipts, and application of authorization state.

Manifest schema v3 derives exact ordinary-user, moderator, and global-admin
authority from each fixed persona name; callers cannot supply or widen it. It
defines `testuser` as a non-administrator with no global capabilities,
`testmoderator` with exactly `global.alert.manage`, `global.alert.read`,
`global.user.manage`, and `global.user.read`, and `testsuperadmin` as a global
administrator with no direct capability assignments. Protected mutations
continue to require normal strong MFA. It also requires an already sorted,
unique
`rpClient.tlsHostnames` inventory containing only exact `localhost` or concrete
lowercase `.localhost` names. It rejects a manifest unless that inventory
covers the hostname of every relying-party app, redirect, and post-logout URI;
explicit additional local TLS surfaces are allowed. The result contract remains
schema v1 and binds the complete manifest through its fingerprint.

## Layout

| Path | Purpose |
| --- | --- |
| `data/index.ts` | Re-exports all shared data interfaces |
| `dto/index.ts` | Re-exports normalized transfer object interfaces |
| `request/index.ts` | Re-exports all typed request contracts |
| `tags/index.ts` | Re-exports shared tags |
| `devidp/index.ts` | Exact local Development IdP public contract |

## Examples

### Login Contract

```ts
type TLogin = request.IReq_LoginWithEmailOrUsernameAndPassword;

const payload: TLogin['request'] = {
  username: 'user@example.com',
  password: 'secret',
};
```

### Session Contract

```ts
type TSessions = request.IReq_GetUserSessions['response']['sessions'];
```

### OIDC Contract

```ts
type TUserInfo = data.IUserInfoResponse;
type TOidcSettings = data.IOidcSettings;
type TJwtVerificationKey = data.IJwtVerificationKey;
type TGetValidationKeys = request.IReq_GetPublicKeysForValidation;
type TPushValidationKeys = request.IReq_PushPublicKeysForValidation;
```

Persisted JWT and login-session data contracts contain no plaintext refresh or
transfer tokens. Transfer-token exchange requires the minimal
`data.ITransferTarget` contract with an `appUrl` for both issue and consume; it
does not expose the removed flat legacy app shape. A session persists only the
atomic `transferTokenHash`, `transferTokenExpiresAt`, and `transferTargetHash`
tuple for an outstanding transfer grant. The target hash is derived
server-side from the canonical, authorized URL, and the raw URL is never
persisted in session data.

Public app contracts contain client type, callback and post-logout URIs,
allowed scopes, grant types, and bounded token lifetime settings. Secret hashes,
private signing keys, and persistence records for authorization codes, access
tokens, refresh tokens, and token families are backend-internal; protocol
values remain public contracts.

## Scope

This package is intentionally contract-only. It does not open sockets, store auth state, or perform HTTP/websocket communication by itself.

## License and Legal Information

This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license](../license) file.

**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

### Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.

Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.

### Company Information

Task Venture Capital GmbH  
Registered at District Court Bremen HRB 35230 HB, Germany

For any legal inquiries or further information, please contact us via email at hello@task.vc.

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
