Skip to content

Take cklib out of the token path — tokenProvider / inject-nc; retire login #14

Description

@styk-tv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1 — this releaseidentityIdentity, admission, attribution

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions