Skip to content

Plugin api: bless getWebIdFromRequestAsync as api.auth.getAgent (request → WebID) #584

Closed

Description

@melvincarvalho

Split out of #206 (plugin-zero results comment): the third seam from the Tideholm mount — and the happiest finding, because no new code is needed, only a public blessing.

Finding

getWebIdFromRequestAsync(request) in src/auth/token.js already does everything an app plugin needs to answer "who is this?": Bearer (IDP-issued), Solid-OIDC DPoP, Nostr NIP-98, and LWS10-CID, uniformly, returning { webId, error }. The Tideholm adapter uses it directly and pod identities become game players with zero auth code of their own ("your WebID is your player").

The problem is only that reaching into src/auth/token.js is an internal import — the function's location, name, and shape are all unwarranted by anything public. Plugin zero works today and breaks the day auth is refactored.

Proposal

Bless it as the loader's identity seam:

api.auth.getAgent(request)   // -> Promise<string|null>  (WebID or null)
  • Thin wrapper over getWebIdFromRequestAsync, returning just the WebID (plugins that want the error detail can get a second method or the raw result later — start minimal).
  • Authentication only, deliberately not authorization: apps under an appPaths prefix (sibling issue) own their own permissioning; WAC stays out of their jurisdiction.
  • Until the loader lands, exporting it from the package root (javascript-solid-server/auth) would give manually-composed apps a stable import path.

Acceptance

  • Stable public accessor for request → WebID covering all four token types
  • Contract test pinning the shape (so auth refactors keep the seam)
  • Tideholm adapter migrated onto it (I'll do this the day it exists)
  • Listed in the Plugin system for JSS #206 api surface next to api.fastify, registerMcpTool, registerPane

Activity

  1. added
    plugin
    on Jul 10, 2026
  2. added a commit that references this issue on Jul 10, 2026
  3. melvincarvalho commented on Jul 10, 2026

    @melvincarvalho
    ContributorAuthor

    Shipped in v0.0.214 (#586, squashed as 327bb01):

    import { getAgent } from 'javascript-solid-server/auth.js';
    
    const agent = await getAgent(request); // WebID or did:nostr DID, null if anonymous

    Contract notes that came out of review:

    • Returns the verified agent identifier — usually an HTTP(S) WebID, but a did:nostr: DID for NIP-98 agents without a WebID mapping. That's deliberate (DID agents are first-class); callers wanting strictly-HTTP WebIDs filter on the prefix.
    • Covers all five credential schemes: IdP Bearer, Solid-OIDC DPoP, Nostr NIP-98, LWS10-CID, WebID-TLS.
    • Bearer verification reads only headers; the signed schemes also read method/url/protocol/hostname — pass the real request.
    • Never throws on bad credentials.

    Acceptance status:

    • Stable public accessor covering all schemes
    • Contract test (test/auth-agent.test.js)
    • Tideholm adapter migrated — b6774da: plugin zero now imports getAgent from javascript-solid-server/auth.js, zero internal-path auth imports remain
    • Listed in the Plugin system for JSS #206 api surface (comment there)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions