Skip to content

examples: pass the config's allowPrivateNetwork to vapiRegistrySource in pay-with-sdk - #152

Open
YudaMau wants to merge 2 commits into
vAPI-Network:mainfrom
YudaMau:main
Open

YudaMau wants to merge 2 commits into
vAPI-Network:mainfrom
YudaMau:main

Conversation

@YudaMau

@YudaMau YudaMau commented Dec 4, 2026

Copy link
Copy Markdown

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.

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