@poly-x/core 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/index.cjs +940 -0
- package/dist/index.d.cts +491 -0
- package/dist/index.d.mts +491 -0
- package/dist/index.mjs +902 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @poly-x/core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic core of the [PolyX](../../README.md) SDK — the shared guts the
|
|
4
|
+
`@poly-x/react`, `@poly-x/next`, and `@poly-x/sdk` packages build on. Most apps
|
|
5
|
+
don't import this directly; reach for the framework package instead.
|
|
6
|
+
|
|
7
|
+
## What's inside
|
|
8
|
+
|
|
9
|
+
- **Key parsing & config** — `parsePolyXKey`, `resolveConfig`. Keys encode their
|
|
10
|
+
issuing deployment host, so one value identifies the app *and* locates its
|
|
11
|
+
PolyX. A secret key reaching the browser throws immediately.
|
|
12
|
+
- **Error taxonomy** — a typed, branchable hierarchy (`PolyXError` →
|
|
13
|
+
`Unauthenticated`, `SessionExpired`, `SessionRevoked`, `Forbidden`,
|
|
14
|
+
`Validation`, `RateLimited`, `Upstream`, `ConfigError`). Key material and
|
|
15
|
+
tokens are redacted on serialization.
|
|
16
|
+
- **Transport** — a `Transport` seam with a fetch implementation (timeout +
|
|
17
|
+
bounded transient retries) and a `MockTransport` for tests.
|
|
18
|
+
- **Session engine** — the auth state machine (`resolving → authenticated ⇄
|
|
19
|
+
refreshing → signed-out`), single-flight refresh with reuse→revoke, cross-tab
|
|
20
|
+
sign-out, and server-authoritative proactive refresh, over swappable seams.
|
|
21
|
+
- **Auth protocol client** — PKCE, authorize-URL building, the membership-outcome
|
|
22
|
+
parse, code exchange, refresh, logout.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createSessionEngine, AuthClient, resolveConfig } from "@poly-x/core";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @poly-x/core
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
MIT licensed. See the [SDK docs](../../docs/) for the full design.
|