Repository navigation
Conversation
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.
What was wrong (one line): The "Discover and pay" example never passes the config's allowPrivateNetwork to vapiRegistrySource, so discovery ignores the setting and dies with NetworkGuardError on any machine whose DNS resolves the registry host to a private-range address — even with "allowPrivateNetwork": true set in config.json.
What this changes
One added line in each of the two places the example appears:
examples/pay-with-sdk.ts — the runnable example
docs/sdk.md — the same "Search and pay" snippet, mirrored
ts
const source = vapiRegistrySource(config.marketplaceDiscoveryUrl, {
discoveryUrl: config.discoveryUrl,
allowPrivateNetwork: config.allowPrivateNetwork ?? false, // added
});
Why
The example loads the config with loadConfig and, a few lines later, passes config.allowPrivateNetwork ?? false to createPublicFetch for the payment probe — but the discovery source is built from the URLs only. The source does accept the option: in @vapi-network/sources, VapiRegistrySourceOptions is GuardedSourceOptions & { discoveryUrl?: string }, and GuardedSourceOptions includes allowPrivateNetwork?: boolean. The loaded config flag simply never reaches the one call that needs it first, so the example's very first step (source.search(...)) is the one that fails, before the wallet is even opened. The added expression is the exact one the same file already uses for createPublicFetch, and it changes nothing for users who never set the flag (the config default is false).
How it was verified
Reproduced live against the published @vapi-network/core / @vapi-network/sources 0.17.5 on a machine whose DNS resolves api.vapinetwork.ai to a 198.18.x.x address:
Example as written, complete config with allowPrivateNetwork: true: source.search("weather") throws NetworkGuardError: URL hostname "api.vapinetwork.ai" is not allowed; private or internal destinations require allowPrivateNetwork true in the vAPI config.
With the added line: search returns results (10 for "weather"), and the rest of the flow (unpaid 402 probe + parse402Response) proceeds as documented.
The patched lines type-check under tsc --strict against the published 0.17.5 package types.