Add RPC support with account-key isolation and custom endpoint URLs#51
Open
johnpmitsch wants to merge 4 commits into
Open
Add RPC support with account-key isolation and custom endpoint URLs#51johnpmitsch wants to merge 4 commits into
johnpmitsch wants to merge 4 commits into
Conversation
RPC calls now go through a dedicated HTTP client that does not carry the account x-api-key default header, so the long-lived account key never leaves the control plane. The data-plane request authenticates only with the short-lived Bearer JWT, as the ephemeral-token design intends. Also redact the JWT in CachedToken's Debug output and drop the unused RpcConfig.base_url field (token minting resolves against the admin base URL, not this field).
Adds an endpoint_url option so callers can point JSON-RPC calls at a fully-formed HTTP URL instead of the provisioned Tooling Access endpoint. A custom URL is treated as self-authenticating: no session token is minted and no Authorization header is attached, only the JSON-RPC POST. Available two ways: RpcConfig.endpoint_url sets a client-wide default, and a per-call endpoint_url argument overrides it. A custom URL is not multichain-routed, so passing both endpoint_url and network returns a Config error. Wired through all four language bindings with examples and README updates.
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.
Adds RPC support to the SDK across all four languages (
qn.rpc.call(...)), plus the admintooling-accessendpoints used to mint the short-lived session tokens RPC calls authenticate with.How it works
RPC data-plane calls authenticate with an ephemeral Bearer JWT minted via the control-plane
tooling-access/tokenendpoint. The client caches the token in memory, refreshes proactively beforeexp, and reactively retries once on a 401. Callers can seed a token from disk viaRpcConfig.seedand route multichain calls viaRpcConfig.networks.Account-key isolation
The point of the ephemeral-token model is that the long-lived account key never reaches the provisioned RPC endpoint. RPC calls go through a dedicated HTTP client that omits the account
x-api-keydefault header, so the data-plane request carries only the Bearer JWT (or nothing, for a custom URL). A test assertsx-api-keyis absent on RPC requests.Custom HTTP URL for RPC calls
endpoint_urlpoints a call at a fully-formed HTTP URL instead of the Tooling Access endpoint. A custom URL is treated as self-authenticating: no token is minted and noAuthorizationheader is attached. Two ways to set it:RpcConfig.endpoint_url(client-wide default)endpoint_urlargument (overrides the default)endpoint_urlandnetworkare mutually exclusive (a custom URL is not multichain-routed) and passing both returns aConfigerror.callsignature and argument combinationscall(method, params?, network?, endpoint_url?)— the two trailing args are independently optional.Rust
Python
Node
Ruby
Passing both
networkandendpoint_urlin any language raises/returns aConfigerror.Also
CachedToken'sDebugredacts the JWT (it's a live credential).RpcConfig.base_urlfield (token minting resolves against the admin base URL).Verification
cargo test(242 pass, incl. new custom-URL tests),just lint,just python-build,just node-build,just ruby-buildall green. Examples updated and syntax-checked in all four languages.