Take cklib out of the token path. cklib currently owns auth: CKClient.login(user,pass) does a direct password grant, holds the token, refreshes, reconnects. With identity server-derived (#12), the client should never mint, hold, or validate a token.
Proposal — two modes
- Mode A — forward-only:
CK.activate('pgCK', { wssEndpoint, tokenProvider: async () => jwt }). cklib forwards the app-supplied token into the NATS CONNECT frame and re-invokes on refresh; it never mints, stores, or validates it. The substrate validates at the admission boundary; a bad/expired token is refused.
- Mode B — inject-
nc (target): CK.activate('pgCK', { nc }). The app builds + authenticates its own NATS connection and injects it; cklib does dispatch/subscribe only and never touches the token. k.close() detaches subscriptions, not the connection.
- Retire
login(user,pass) from the L2 story (legacy only). No token → anonymous.
Dependency
None on pgCK — the substrate already validates the presented token at admission and supports anonymous. Client-side only; can proceed independently.
Done-when
- No password grant / token mint / token storage in the cklib dispatch path.
- Mode A forwards + reconnects on refresh (browser + CLI); Mode B injects with correct lifecycle.
- Docs updated (auth model in
SPEC.CK-LIB-JS / SPEC.CK-OPERATIONS / GUIDE).
Relates
Take cklib out of the token path. cklib currently owns auth:
CKClient.login(user,pass)does a direct password grant, holds the token, refreshes, reconnects. With identity server-derived (#12), the client should never mint, hold, or validate a token.Proposal — two modes
CK.activate('pgCK', { wssEndpoint, tokenProvider: async () => jwt }). cklib forwards the app-supplied token into the NATSCONNECTframe and re-invokes on refresh; it never mints, stores, or validates it. The substrate validates at the admission boundary; a bad/expired token is refused.nc(target):CK.activate('pgCK', { nc }). The app builds + authenticates its own NATS connection and injects it; cklib does dispatch/subscribe only and never touches the token.k.close()detaches subscriptions, not the connection.login(user,pass)from the L2 story (legacy only). No token → anonymous.Dependency
None on pgCK — the substrate already validates the presented token at admission and supports anonymous. Client-side only; can proceed independently.
Done-when
SPEC.CK-LIB-JS/SPEC.CK-OPERATIONS/GUIDE).Relates