fix(javascript-provider): request the API audience on login - #102
Open
vriveraPeersyst wants to merge 1 commit into
Open
vriveraPeersyst wants to merge 1 commit into
vriveraPeersyst wants to merge 1 commit into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
JavascriptProviderlogin 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 emptyauthorizationParams:So a plain
login()sends no audience → Auth0 applies the tenant Default Audience (auth0.jwt.fast-auth.near, the signing audience) → the post-loginauthorize-appAction denies it:(
authorize-app.action.js:isOnchainAudience && !hasSigningPayload → deny(...); a login carries no transaction payload.)Fix
Login now requests the API audience (
https://api.auth.near.org) →event.resource_server.identifier !== ONCHAIN_AUDIENCE→ the Action'sif (!isOnchainAudience) returnallows it. Signature requests are unaffected —requestTransactionSignature/getSignatureRequestoverrideaudiencewithsigningAudienceand send a transaction payload.Verified
pnpm testinpackages/providers/javascript: 45/45 pass (added a regression test asserting the constructor passes the network's API audience).?error=access_denied&error_description=Signing%20audience%20requested%20without%20transaction%20payload. This fix makes login request the API audience instead.🤖 Generated with Claude Code