Skip to content

fix(javascript-provider): request the API audience on login - #102

Open
vriveraPeersyst wants to merge 1 commit into
mainfrom
fix/js-provider-login-audience
Open

vriveraPeersyst wants to merge 1 commit into
mainfrom
fix/js-provider-login-audience

Conversation

@vriveraPeersyst

Copy link
Copy Markdown
Contributor

Problem

JavascriptProvider login can never succeed against a tenant whose Default Audience is the on-chain signing audience (which mainnet is).

The constructor computes defaults.audience (the network's API audience) but never uses it — the Auth0Client is built with an empty authorizationParams:

const defaults = FAST_AUTH_AUTH0_DEFAULTS[options.network]; // .audience = https://api.auth.near.org
...
this.client = new Auth0Client({
    domain, clientId,
    authorizationParams: {},   // ← API audience dropped
});

So a plain login() sends no audience → Auth0 applies the tenant Default Audience (auth0.jwt.fast-auth.near, the signing audience) → the post-login authorize-app Action denies it:

error=access_denied
error_description=Signing audience requested without transaction payload

(authorize-app.action.js: isOnchainAudience && !hasSigningPayload → deny(...); a login carries no transaction payload.)

Fix

- authorizationParams: {},
+ authorizationParams: { audience: defaults.audience },

Login now requests the API audience (https://api.auth.near.org) → event.resource_server.identifier !== ONCHAIN_AUDIENCE → the Action's if (!isOnchainAudience) return allows it. Signature requests are unaffected — requestTransactionSignature / getSignatureRequest override audience with signingAudience and send a transaction payload.

Verified

  • pnpm test in packages/providers/javascript: 45/45 pass (added a regression test asserting the constructor passes the network's API audience).
  • Reproduced end-to-end on a mainnet app (neartrader4, SDK 1.4.1): the redirect returned exactly ?error=access_denied&error_description=Signing%20audience%20requested%20without%20transaction%20payload. This fix makes login request the API audience instead.

🤖 Generated with Claude Code

The JavascriptProvider constructor computed `defaults.audience` (the network's
API audience, e.g. https://api.auth.near.org) but dropped it — it built the
Auth0Client with `authorizationParams: {}`. So a plain login sent no audience
and Auth0 fell back to the tenant's Default Audience (the on-chain signing
audience). The post-login authorize-app Action then denied it with
"Signing audience requested without transaction payload", since a login carries
no transaction.

Set `authorizationParams: { audience: defaults.audience }` so login requests the
API audience explicitly. Signature requests still override it with
`signingAudience`. Adds a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fast-auth-landing Ready Ready Preview, Comment Jul 21, 2026 4:26pm
fast-auth-spa Ready Ready Preview, Comment Jul 21, 2026 4:26pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant