@authms/core
v0.2.2
Published
AuthMS Core SDK — framework-agnostic token management, API client, and auth flows
Maintainers
Readme
@autional/core
Autional Core SDK — framework-agnostic token management, API client, and authentication flows.
What's Inside
Autional— main client: login, register, logout, OAuth, token refresh, tenant switching, event systemApiClient— HTTP client with auto token injection, refresh on 401, and snake_case/camelCase conversionAuthClient— authentication calls with password transmission preprocessing and PoW captcha solvingDiscovery— OIDC discovery document fetchingTokenManager— access/refresh token storage, JWT decoding, expiry trackingTabSync— cross-tab session synchronization via BroadcastChannelbrowserPlatform/memoryPlatform— ready-made platform bindings for browsers and SSR/memory
Install
npm install @autional/coreQuick Start
import { Autional, browserPlatform } from '@autional/core';
const authms = new Autional({
appId: 'my-app',
issuer: 'https://auth.iam.tianv.com',
platform: browserPlatform,
});
await authms.initialize();
await authms.login({ email: '[email protected]', password: 's3cret' });
const profile = await authms.api.get('/profile/api/v1/profiles/me');
console.log(profile);Password Transmission
processPasswordForTransmission preprocesses passwords based on tenant policy with 4 modes:
| Mode | Transport | Description |
|------|-----------|-------------|
| plain | Raw password | No processing |
| hash | SHA-256(password + "|" + tenantId) | Client-side hashing with separator |
| symmetric | ECDH + AES-256-GCM | Key exchange, encrypted |
| asymmetric | RSA-OAEP | Public-key encrypted |
The SDK reads the mode from TenantAuthConfig.passwordPolicy.mode and applies it automatically on login/register/change-password.
Project Setup
For framework integration, pick the example for your framework: examples/react-authms.ts, examples/vue-authms.ts, or examples/next-authms.ts. Copy to src/authms.ts, edit appId and issuer.
See the root SDK README for full documentation.
