mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-17 07:04:36 +00:00
src/tokens/principal.ts: userToken, username, displayName, scopes, and the upstream credential. The provider hands the protected handler only the decrypted grant props, so finishAuthorization now stores userToken and the granted scopes in props alongside the credential and issue time; principalFromProps validates all of it and fails closed with PrincipalError (→ 403) on anything this build does not understand — unknown scopes, wrong token prefix, unrecognised credential kind, missing issue time. Personal tokens (M2) will produce the same props through resolveExternalToken and land on the same function. Also drops @hono/mcp: the SDK's WebStandardStreamableHTTPServerTransport is the right fit for Workers and carries our principal via AuthInfo.extra. Tests (8): rebuild, scope checks, no credential leak through JSON, and the fail-closed cases. Claude-Session: https://claude.ai/code/session_01H3gfN2NCx3hBXSrZXYHUQ3