feat(sdk): add WebBotAuthResource for Web Bot Auth header minting#105
Merged
Conversation
Contributor
danhill-stripe
left a comment
There was a problem hiding this comment.
looks good! couple small comments.
| this.getAccessToken = config.getAccessToken; | ||
| this.fetchImpl = requireFetchImplementation(config); | ||
| this.credentialsEndpoint = `${config.apiBaseUrl}/v1/agent_identity/credentials`; | ||
| this.logger = config.logger; |
Contributor
There was a problem hiding this comment.
also defaultHeaders?
Contributor
Author
There was a problem hiding this comment.
defaultHeaders is already applied by resolveLinkSdkConfig via reateDefaultHeadersFetch. added a comment.
|
|
||
| this.cache.set(authority, { | ||
| block: webBotAuth, | ||
| expiresAt: Date.parse(webBotAuth.expires_at), |
Contributor
There was a problem hiding this comment.
handle if expires_at is bad/malformed?
Contributor
Author
There was a problem hiding this comment.
added explicit NaN check after Date.parse. Previously a bad expires_at would produce NaN as expiresAt, causing the cache condition Date.now() < NaN to silently always be false; every subsequent call would re-fetch. Now throws a LinkSdkError with the bad value in the message. Added a test for this case.
danhill-stripe
approved these changes
May 20, 2026
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.
r? @kreese-stripe @danhill-stripe @bendavis-stripe
Summary and motivation
Adds
WebBotAuthResourceto@stripe/link-sdkthe SDK component that fetches pre-signed Web Bot Auth headers from the Link backend so AI agents can prove their identity to merchant sites protected by Cloudflare bot filtering.What this adds:
WebBotAuthBlocktype in mirroring the backend response shape:{ signature, signature_input, signature_agent, authority, expires_at }.IWebBotAuthResourceinterface with a single method:getHeaders(url: string): Promise<WebBotAuthBlock>.WebBotAuthResourceclass implementing the interface. OngetHeaders(url):more than 30 seconds in the future.
POST /v1/agent_identity/credentials(authenticated with theuser's Link OAuth bearer token) with
{ url }as the JSON body.web_bot_authblock from the response, caches it keyed by hostname,and returns it.
WebBotAuthResourcewired intoResourceFactoryin the CLI package with lazy caching,same as
SpendRequestResource,PaymentMethodsResource, etc.Why:
AI agents using Link CLI to complete checkout on merchant sites get blocked by Cloudflare and Vercel's automated bot detection: their traffic is indistinguishable from scraper traffic.
Web Bot Auth is an IETF-draft protocol where registered bots attach a cryptographic signature to every request, allowing CDN/WAF managed rulesets to bypass bot challenges without user interaction.
Signatures are valid for 10 minutes. The per-authority cache avoids a round-trip to
api.link.comon every request to the same merchant domain within that window.Test plan
packages/sdk/src/resources/__tests__/web-bot-auth.test.ts(11 new unit tests).packages/cli/src/utils/__tests__/resource-factory.test.tsupdated:createWebBotAuthResource()returns cached instance on repeated callsinstanceof WebBotAuthResource