2026-04-20 08:15:42 +00:00
# @idp.global/client
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
Browser-facing TypeScript client for talking to an `idp.global` server over `typedrequest` and `typedsocket` .
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
It handles login state, refresh tokens, JWT housekeeping, cross-app transfer tokens, and direct access to the typed request surface.
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
## Issue Reporting and Security
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
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
2025-12-16 12:46:42 +00:00
``` bash
2026-04-20 08:15:42 +00:00
pnpm add @idp.global/client
2025-12-16 12:46:42 +00:00
```
## Quick Start
2026-04-20 08:15:42 +00:00
``` ts
import { IdpClient } from '@idp.global/client' ;
2025-12-16 12:46:42 +00:00
const idpClient = new IdpClient ( 'https://idp.global' ) ;
await idpClient . enableTypedSocket ( ) ;
2026-04-20 08:15:42 +00:00
const loggedIn = await idpClient . determineLoginStatus ( ) ;
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
if ( ! loggedIn ) {
const loginResult = await idpClient . requests . loginWithUserNameAndPassword . fire ( {
username : 'user@example.com' ,
password : 'secret' ,
} ) ;
if ( loginResult . refreshToken ) {
await idpClient . refreshJwt ( loginResult . refreshToken ) ;
}
2025-12-16 12:46:42 +00:00
}
2026-04-20 08:15:42 +00:00
const whoIs = await idpClient . whoIs ( ) ;
console . log ( whoIs . user . data . email ) ;
2025-12-16 12:46:42 +00:00
```
2026-04-20 08:15:42 +00:00
## What The Client Handles
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
- Normalizes the base URL to the server's `/typedrequest` endpoint.
- Stores JWT and refresh token state in a browser `WebStore` .
- Refreshes expiring JWTs via `performJwtHousekeeping()` .
- Redirects to `/login` when `determineLoginStatus(true)` is used.
- Exchanges refresh tokens for cross-app transfer tokens.
- Exposes the low-level typed requests through `idpClient.requests` .
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
## Common Flows
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
### Password Login
``` ts
const result = await idpClient . requests . loginWithUserNameAndPassword . fire ( {
2025-12-16 12:46:42 +00:00
username : 'user@example.com' ,
2026-04-20 08:15:42 +00:00
password : 'secret' ,
2025-12-16 12:46:42 +00:00
} ) ;
2026-04-20 08:15:42 +00:00
if ( result . refreshToken ) {
await idpClient . refreshJwt ( result . refreshToken ) ;
2025-12-16 12:46:42 +00:00
}
```
2026-04-20 08:15:42 +00:00
### Magic Link Login
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
``` ts
2025-12-16 12:46:42 +00:00
await idpClient . requests . loginWithEmail . fire ( {
email : 'user@example.com' ,
} ) ;
const result = await idpClient . requests . loginWithEmailAfterToken . fire ( {
email : 'user@example.com' ,
2026-04-20 08:15:42 +00:00
token : 'token-from-email' ,
2025-12-16 12:46:42 +00:00
} ) ;
2026-04-20 08:15:42 +00:00
await idpClient . refreshJwt ( result . refreshToken ) ;
2025-12-16 12:46:42 +00:00
```
2026-04-20 08:15:42 +00:00
### Session and Identity
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
``` ts
await idpClient . performJwtHousekeeping ( ) ;
2025-12-16 12:46:42 +00:00
const jwt = await idpClient . getJwt ( ) ;
const jwtData = await idpClient . getJwtData ( ) ;
2026-04-20 08:15:42 +00:00
const whoIs = await idpClient . whoIs ( ) ;
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
console . log ( jwtData . id , whoIs . user . data . username ) ;
2025-12-16 12:46:42 +00:00
```
2026-04-20 08:15:42 +00:00
### Organizations
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
``` ts
const rolesAndOrganizations = await idpClient . getRolesAndOrganizations ( ) ;
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
const created = await idpClient . createOrganization (
'Acme' ,
'acme' ,
'manifest'
2025-12-16 12:46:42 +00:00
) ;
const members = await idpClient . requests . getOrgMembers . fire ( {
jwt : await idpClient . getJwt ( ) ,
2026-04-20 08:15:42 +00:00
organizationId : created.resultingOrganization.id ,
2025-12-16 12:46:42 +00:00
} ) ;
```
2026-04-20 08:15:42 +00:00
### Cross-App Transfer
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
``` ts
2025-12-16 12:46:42 +00:00
const transferToken = await idpClient . getTransferToken ( ) ;
await idpClient . getTransferTokenAndSwitchToLocation ( 'https://app.example.com/' ) ;
```
2026-04-20 08:15:42 +00:00
## Typed Request Surface
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
`IdpRequests` exposes typed request getters for:
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
- authentication
- registration
- user/session queries
- org and invitation management
- billing requests
- JWT validation key requests
- admin requests
2026-05-07 15:35:37 +00:00
- OIDC authorization preparation and completion
- passport device enrollment, challenge approval, alert, and push-token requests
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
Use these when you want full control instead of the higher-level helper methods on `IdpClient` .
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
## Important Runtime Notes
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
- The default fallback `appData` uses `window.location` , so this package is primarily browser-oriented.
- The client expects the backend `typedrequest` websocket surface to be reachable.
- Auth state is persisted in browser storage under the `idpglobalStore` store name.
2026-05-07 15:35:37 +00:00
- Passport, alert, and OIDC helper flows are available through `idpClient.requests` even when there is no higher-level convenience method on `IdpClient` yet.
2025-12-16 12:46:42 +00:00
2026-01-29 14:24:08 +00:00
## License and Legal Information
2025-12-16 12:46:42 +00:00
2026-04-20 08:15:42 +00:00
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [license ](../license ) file.
2026-01-29 14:24:08 +00:00
**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
2026-04-20 08:15:42 +00:00
Task Venture Capital GmbH
2026-01-29 14:24:08 +00:00
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.