@piprail/sdk 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -216,9 +216,6 @@ type VerifyResult = {
216
216
  declare const HEADER_REQUIRED = "payment-required";
217
217
  declare const HEADER_SIGNATURE = "payment-signature";
218
218
  declare const HEADER_RESPONSE = "payment-response";
219
- /** Legacy x402 v1 header names. PipRail EMITS v2 (the constants above) but also
220
- * READS the v1 client header and ECHOES the v1 response header, so a deprecated
221
- * v1 client (still ~half the installed base) interoperates on the `exact` rail. */
222
219
  declare const HEADER_SIGNATURE_V1 = "x-payment";
223
220
  declare const HEADER_RESPONSE_V1 = "x-payment-response";
224
221
  declare function buildChallengeHeader(challenge: X402Challenge): string;
@@ -4237,6 +4234,14 @@ interface DiscoveredResource {
4237
4234
  /** The payment options the index advertises (best-effort, cross-scheme). */
4238
4235
  rails: DiscoveredRail[];
4239
4236
  }
4237
+ /** Where a listing stands after a register attempt — a branchable lifecycle
4238
+ * state so an agent doesn't have to re-derive each index's behaviour:
4239
+ * - `'live'` — findable now (search it immediately).
4240
+ * - `'pending-review'` — accepted, but the index reviews/propagates before it's
4241
+ * publicly findable; allow a short delay before `discover()`.
4242
+ * - `'not-listable'` — it didn't list (a failure, or this index structurally
4243
+ * can't list a PipRail resource). See `detail` + `note`. */
4244
+ type ListingVisibility = 'live' | 'pending-review' | 'not-listable';
4240
4245
  /** The result of trying to list a resource on one open index. */
4241
4246
  interface RegisterOutcome {
4242
4247
  source: DiscoverySource;
@@ -4247,6 +4252,14 @@ interface RegisterOutcome {
4247
4252
  detail?: string;
4248
4253
  /** A link to the listing, when the index returns one. */
4249
4254
  listingUrl?: string;
4255
+ /** The lifecycle state of this listing — `'live'`, `'pending-review'`, or
4256
+ * `'not-listable'`. Projected from {@link DIRECTORY_INFO}; branch on this
4257
+ * instead of guessing how soon `discover()` will find the resource. */
4258
+ visibility?: ListingVisibility;
4259
+ /** A one-line, agent-readable caveat for this source (from {@link DIRECTORY_INFO})
4260
+ * — e.g. "402 Index reviews before publishing" or "discover() doesn't read
4261
+ * x402scan, so a live listing there won't appear in discover() results". */
4262
+ note?: string;
4250
4263
  }
4251
4264
  interface SearchOpenIndexesOptions {
4252
4265
  /** Free-text query (filtered client-side against name/description/resource). */
@@ -4278,6 +4291,48 @@ interface RegisterInput {
4278
4291
  */
4279
4292
  attribution?: boolean;
4280
4293
  }
4294
+ /**
4295
+ * Static, agent-readable lifecycle facts about one open index — the SINGLE source
4296
+ * of truth that {@link RegisterOutcome.visibility}/`note` are projected from, and
4297
+ * that an agent can also query directly (via {@link getDirectoryInfo}) to reason
4298
+ * about an index BEFORE calling. Best-effort: an index can change its behaviour,
4299
+ * so treat the timing as guidance, not an SLA.
4300
+ */
4301
+ interface DirectoryInfo {
4302
+ source: DiscoverySource;
4303
+ /** How a new listing is gated: a synchronous URL probe (`402index`, `x402scan`),
4304
+ * or coupled to a facilitator settling a payment (`bazaar`). */
4305
+ review: 'probe-sync' | 'settle-coupled';
4306
+ /** Auth needed to WRITE a listing. */
4307
+ auth: 'none' | 'siwx' | 'facilitator-only';
4308
+ /** Chains (CAIP-2) this index will list. `null` = any chain the resource advertises. */
4309
+ chains: readonly string[] | null;
4310
+ /** Visibility a SUCCESSFUL listing reaches here (the steady state a non-failed
4311
+ * outcome maps to). */
4312
+ onSuccess: ListingVisibility;
4313
+ /** Whether THIS SDK's {@link PipRailClient.discover} reads this index. It reads
4314
+ * `bazaar` + `402index`; it does NOT read `x402scan` — so a live x402scan listing
4315
+ * won't appear in `discover()` results. Don't read that absence as failure. */
4316
+ readByDiscover: boolean;
4317
+ /** One-line caveat: why a register might fail, or what to expect afterwards. */
4318
+ caveat: string;
4319
+ }
4320
+ /**
4321
+ * The open directories' lifecycle, as one queryable map. An agent can branch on
4322
+ * this without embedding directory knowledge: `DIRECTORY_INFO[source].readByDiscover`,
4323
+ * `.chains`, `.onSuccess`, etc. {@link PipRailClient.register} projects the relevant
4324
+ * entry onto every {@link RegisterOutcome} (`visibility` + `note`).
4325
+ */
4326
+ declare const DIRECTORY_INFO: Readonly<Record<DiscoverySource, DirectoryInfo>>;
4327
+ /** Lifecycle facts for one open index (auth, chains, how soon a listing is
4328
+ * findable, whether `discover()` reads it). See {@link DIRECTORY_INFO}. The param
4329
+ * is the closed {@link DiscoverySource} union (TS callers are safe); a string
4330
+ * outside it returns `undefined` at runtime. */
4331
+ declare function getDirectoryInfo(source: DiscoverySource): DirectoryInfo;
4332
+ /** Project the static {@link DIRECTORY_INFO} lifecycle facts onto a register
4333
+ * outcome, so an agent gets `visibility` + `note` in the result it already holds —
4334
+ * no second lookup. A failed outcome is always `'not-listable'`. Idempotent. */
4335
+ declare function decorateOutcome(o: RegisterOutcome): RegisterOutcome;
4281
4336
  /** Normalize an index's network field to CAIP-2 when we recognise the slug;
4282
4337
  * pass a value that's already CAIP-2 (`namespace:reference`) through unchanged.
4283
4338
  * An unknown slug returns unchanged (no `:`), which the client treats as
@@ -4291,8 +4346,11 @@ declare function normalizeNetwork(network: string): string;
4291
4346
  declare function searchOpenIndexes(opts?: SearchOpenIndexesOptions): Promise<DiscoveredResource[]>;
4292
4347
  /**
4293
4348
  * Register a resource on **402 Index** — the primary, friction-free path: a
4294
- * single POST, no auth, no signature, no payment. Searchable within seconds.
4295
- * Returns a structured outcome; never throws for an HTTP/transport problem.
4349
+ * single POST, no auth, no signature, no payment. A self-registered listing is
4350
+ * **pending review** (not searchable until approved verify your domain on
4351
+ * 402index.io for instant approval). Returns a structured outcome; never throws
4352
+ * for an HTTP/transport problem. NOTE: the outcome is BARE — `visibility`/`note`
4353
+ * are added by {@link PipRailClient.register} (or call {@link decorateOutcome}).
4296
4354
  */
4297
4355
  declare function register402Index(input: RegisterInput): Promise<RegisterOutcome>;
4298
4356
  /**
@@ -4300,11 +4358,57 @@ declare function register402Index(input: RegisterInput): Promise<RegisterOutcome
4300
4358
  * EIP-4361 challenge with the merchant's own key, resend with the
4301
4359
  * `SIGN-IN-WITH-X` header. Facilitator-free, but **Base/Solana-only** and EVM
4302
4360
  * signing today. EXPERIMENTAL — the open SIWX handshake is a moving convention;
4303
- * validate against x402scan before relying on it. Never throws.
4361
+ * validate against x402scan before relying on it. Never throws. NOTE: returns a
4362
+ * BARE outcome — `visibility`/`note` are added by {@link PipRailClient.register}
4363
+ * (or call {@link decorateOutcome}).
4304
4364
  */
4305
4365
  declare function registerX402Scan(input: {
4306
4366
  url: string;
4307
4367
  }, signer: DiscoverySigner): Promise<RegisterOutcome>;
4368
+ /** What {@link claim402IndexDomain} returns — the proof to SERVE so 402 Index will
4369
+ * approve your domain (and flip your `pending-review` listings to searchable). */
4370
+ interface DomainClaim {
4371
+ ok: boolean;
4372
+ domain: string;
4373
+ /** Serve THIS string as the entire body of `verificationUrl`. */
4374
+ verificationHash?: string;
4375
+ /** Where to serve it — your `https://<domain>/.well-known/402index-verify.txt`. */
4376
+ verificationUrl?: string;
4377
+ /** 402 Index's own human instructions. */
4378
+ instructions?: string;
4379
+ httpStatus?: number;
4380
+ /** Failure reason when `ok:false`. */
4381
+ detail?: string;
4382
+ }
4383
+ /** What {@link verify402IndexDomain} returns once the proof is in place. */
4384
+ interface DomainVerification {
4385
+ ok: boolean;
4386
+ domain: string;
4387
+ /** 402 Index's status string, e.g. `'verified'`. */
4388
+ status?: string;
4389
+ /** How many of your pending listings were approved by the verification. */
4390
+ servicesCount?: number;
4391
+ httpStatus?: number;
4392
+ detail?: string;
4393
+ }
4394
+ /**
4395
+ * Step 1 of 402 Index domain verification: claim the host of `domainOrUrl`. 402 Index
4396
+ * lists a self-registered resource as PENDING REVIEW; verifying the domain approves it
4397
+ * (and every other pending listing on that domain) so it becomes searchable. Returns the
4398
+ * `verificationHash` to serve as the entire body of `verificationUrl`
4399
+ * (`https://<domain>/.well-known/402index-verify.txt`). Then call {@link verify402IndexDomain}.
4400
+ * No funds move. Never throws.
4401
+ */
4402
+ declare function claim402IndexDomain(domainOrUrl: string, opts?: {
4403
+ contactEmail?: string;
4404
+ }): Promise<DomainClaim>;
4405
+ /**
4406
+ * Step 2 of 402 Index domain verification: after {@link claim402IndexDomain} and serving
4407
+ * the `verificationHash` at `verificationUrl`, tell 402 Index to re-fetch + approve. On
4408
+ * success, the domain's pending listings become searchable (`status:'verified'`,
4409
+ * `servicesCount` approved). No funds move. Never throws.
4410
+ */
4411
+ declare function verify402IndexDomain(domainOrUrl: string): Promise<DomainVerification>;
4308
4412
 
4309
4413
  interface PaymentPolicy {
4310
4414
  /** Per-payment ceiling, human-readable (e.g. '0.10'). Compared using the
@@ -4753,21 +4857,66 @@ declare class PipRailClient {
4753
4857
  *
4754
4858
  * Nothing PipRail-hosted: these are third-party open directories. Never throws
4755
4859
  * for a read problem — an index that's down or changed simply contributes
4756
- * nothing. Honest caveat: index results are cross-scheme (mostly the
4757
- * mainstream `exact` scheme); `fetch()` pays only `onchain-proof` rails
4758
- * directly (pay `exact` resources with the experimental `drivers/evm/exact.ts`).
4860
+ * nothing. Honest caveats (see {@link DIRECTORY_INFO}):
4861
+ * - Reads **`bazaar` + `402index`** only — **NOT `x402scan`** (its reads are paid). A
4862
+ * resource you registered on x402scan is live there but will NOT appear here; don't
4863
+ * read that absence as failure. (Passing `sources:['x402scan']` explicitly yields `[]`.)
4864
+ * - A resource just listed via {@link register} may not appear yet — 402 Index reviews
4865
+ * before publishing, so retry with a brief backoff if a fresh listing is missing.
4866
+ * - Results are cross-scheme (mostly the mainstream `exact` scheme); `fetch()` pays
4867
+ * only `onchain-proof` rails directly (pay `exact` resources with the experimental
4868
+ * `drivers/evm/exact.ts`).
4759
4869
  */
4760
4870
  discover(opts?: DiscoverOptions): Promise<DiscoveredResource[]>;
4761
4871
  /**
4762
4872
  * List a resource you run on the OPEN x402 registries, so agents can find it.
4763
- * Default target is **402 Index** — one POST, no auth, no signature, no payment
4764
- * (searchable within seconds). Add `'x402scan'` to also register via SIWX (one
4765
- * wallet signature; EVM + a Base/Solana rail). Returns one {@link RegisterOutcome}
4766
- * per target — a target the chain can't satisfy comes back `{ ok:false, detail }`,
4767
- * never a throw. An explicit, developer-invoked action; it moves no funds, and
4768
- * nothing is PipRail-hosted — you're listing on third-party open directories.
4873
+ * Default target is **402 Index** — one POST, no auth, no signature, no payment.
4874
+ * Add `'x402scan'` to also register via SIWX (one wallet signature; EVM + a
4875
+ * Base/Solana rail). Returns one {@link RegisterOutcome} per target — a target the
4876
+ * chain can't satisfy comes back `{ ok:false, detail }`, never a throw. An explicit,
4877
+ * developer-invoked action; it moves no funds, and nothing is PipRail-hosted —
4878
+ * you're listing on third-party open directories.
4879
+ *
4880
+ * **Listing is asynchronous — each outcome carries a `visibility` + `note` so an
4881
+ * agent knows when/where the resource is findable (don't assume `ok:true` means
4882
+ * "searchable now"):**
4883
+ * - **402 Index** → `visibility:'pending-review'`. It probes your URL on submit, then lists it
4884
+ * PENDING REVIEW — not searchable until approved (verify your domain on 402index.io for instant
4885
+ * approval), so `discover()` returns nothing for a fresh listing until then. Retry later.
4886
+ * - **x402scan** → `visibility:'live'`, but **`discover()` does NOT read x402scan** — the
4887
+ * listing is real on x402scan.com yet won't show up in `discover()`. Base/Solana only;
4888
+ * needs a resolvable input schema (`/openapi.json` or the `extensions.bazaar` block).
4889
+ * - **Bazaar** → `visibility:'not-listable'` for PipRail (it lists only what its facilitator
4890
+ * settles; PipRail uses none). You can still READ Bazaar via {@link discover} to find others.
4891
+ *
4892
+ * The per-source facts live in {@link DIRECTORY_INFO} (importable) if you'd rather branch
4893
+ * on them before calling.
4769
4894
  */
4770
4895
  register(url: string, opts?: RegisterOptions): Promise<RegisterOutcome[]>;
4896
+ /**
4897
+ * **402 Index domain verification, step 1 of 2.** A self-registered 402 Index
4898
+ * listing is `pending-review` (see {@link register}); verifying your domain flips
4899
+ * it — and every other pending listing on that domain — to APPROVED/searchable.
4900
+ * Pass the resource URL or a bare domain; returns the `verificationHash` to serve
4901
+ * as the entire body of `verificationUrl` (your `/.well-known/402index-verify.txt`).
4902
+ * Then serve it and call {@link verifyDomain}. Moves no funds; never throws.
4903
+ *
4904
+ * ```ts
4905
+ * const claim = await client.claimDomain('https://api.example.com/report')
4906
+ * // serve claim.verificationHash at claim.verificationUrl, then:
4907
+ * const res = await client.verifyDomain('api.example.com') // → { ok:true, status:'verified' }
4908
+ * ```
4909
+ */
4910
+ claimDomain(urlOrDomain: string, opts?: {
4911
+ contactEmail?: string;
4912
+ }): Promise<DomainClaim>;
4913
+ /**
4914
+ * **402 Index domain verification, step 2 of 2.** After {@link claimDomain} and
4915
+ * serving the hash at your `/.well-known/402index-verify.txt`, this tells 402 Index
4916
+ * to re-fetch + approve. On success the domain's pending listings become searchable
4917
+ * (`{ ok:true, status:'verified', servicesCount }`). Moves no funds; never throws.
4918
+ */
4919
+ verifyDomain(urlOrDomain: string): Promise<DomainVerification>;
4771
4920
  /**
4772
4921
  * The discovery signer for the bound wallet (its address + a message signer),
4773
4922
  * or `null` if the chain family doesn't support it (EVM does today). For
@@ -5619,12 +5768,21 @@ declare function buildExactAuthorization(params: BuildExactParams): Promise<{
5619
5768
  authorization: ExactAuthorization;
5620
5769
  signature: Hex;
5621
5770
  }>;
5622
- /** Encode an x402 `exact` PaymentPayload into an `X-PAYMENT` header value. */
5771
+ /**
5772
+ * Encode an x402 `exact` PaymentPayload into an `X-PAYMENT` header value — the
5773
+ * **v1 flat shape** (`{ x402Version, scheme, network, payload }`). This is a
5774
+ * client-side UTILITY (PipRail's own client pays only `onchain-proof`, never this);
5775
+ * the v1 flat shape is what Coinbase's original reference emits and is still accepted
5776
+ * by every x402 gate + facilitator, so `x402Version` defaults to `1` to stay
5777
+ * INTERNALLY CONSISTENT with that shape (emitting `2` here would mislabel a v1 body —
5778
+ * a proper v2 `exact` payload is the nested `accepted`-envelope shape instead). See
5779
+ * the version-posture note in `x402.ts`.
5780
+ */
5623
5781
  declare function encodeXPaymentHeader(input: {
5624
5782
  network: string;
5625
5783
  authorization: ExactAuthorization;
5626
5784
  signature: Hex;
5627
- /** x402 envelope version (Coinbase's reference uses 1). */
5785
+ /** x402 envelope version. Defaults to `1` — consistent with this flat shape. */
5628
5786
  x402Version?: number;
5629
5787
  }): string;
5630
5788
  /**
@@ -5740,4 +5898,4 @@ declare function readExactDomain(publicClient: PublicClient, asset: string): Pro
5740
5898
  version: string;
5741
5899
  } | null>;
5742
5900
 
5743
- export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExactAuthorizationWire, type ExactPaymentPayload, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, GENERATOR, HEADER_REQUIRED, HEADER_RESPONSE, HEADER_RESPONSE_V1, HEADER_SIGNATURE, HEADER_SIGNATURE_V1, InsufficientFundsError, InvalidEnvelopeError, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type ParsedExactPayment, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SettleViaFacilitatorInput, SettlementError, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402AnyAccept, type X402Challenge, type X402DnsRecord, type X402ExactAcceptEntry, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, createPaymentGate, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, normalizeNetwork, parseChallenge, parseExactPaymentHeader, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, readExactDomain, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, settleViaFacilitator, toInsufficientFundsError, toInvalidBody };
5901
+ export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, DIRECTORY_INFO, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExactAuthorizationWire, type ExactPaymentPayload, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, GENERATOR, HEADER_REQUIRED, HEADER_RESPONSE, HEADER_RESPONSE_V1, HEADER_SIGNATURE, HEADER_SIGNATURE_V1, InsufficientFundsError, InvalidEnvelopeError, type ListingVisibility, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type ParsedExactPayment, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SettleViaFacilitatorInput, SettlementError, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402AnyAccept, type X402Challenge, type X402DnsRecord, type X402ExactAcceptEntry, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, createPaymentGate, decorateOutcome, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, getDirectoryInfo, normalizeNetwork, parseChallenge, parseExactPaymentHeader, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, readExactDomain, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, settleViaFacilitator, toInsufficientFundsError, toInvalidBody, verify402IndexDomain };
package/dist/index.d.ts CHANGED
@@ -216,9 +216,6 @@ type VerifyResult = {
216
216
  declare const HEADER_REQUIRED = "payment-required";
217
217
  declare const HEADER_SIGNATURE = "payment-signature";
218
218
  declare const HEADER_RESPONSE = "payment-response";
219
- /** Legacy x402 v1 header names. PipRail EMITS v2 (the constants above) but also
220
- * READS the v1 client header and ECHOES the v1 response header, so a deprecated
221
- * v1 client (still ~half the installed base) interoperates on the `exact` rail. */
222
219
  declare const HEADER_SIGNATURE_V1 = "x-payment";
223
220
  declare const HEADER_RESPONSE_V1 = "x-payment-response";
224
221
  declare function buildChallengeHeader(challenge: X402Challenge): string;
@@ -4237,6 +4234,14 @@ interface DiscoveredResource {
4237
4234
  /** The payment options the index advertises (best-effort, cross-scheme). */
4238
4235
  rails: DiscoveredRail[];
4239
4236
  }
4237
+ /** Where a listing stands after a register attempt — a branchable lifecycle
4238
+ * state so an agent doesn't have to re-derive each index's behaviour:
4239
+ * - `'live'` — findable now (search it immediately).
4240
+ * - `'pending-review'` — accepted, but the index reviews/propagates before it's
4241
+ * publicly findable; allow a short delay before `discover()`.
4242
+ * - `'not-listable'` — it didn't list (a failure, or this index structurally
4243
+ * can't list a PipRail resource). See `detail` + `note`. */
4244
+ type ListingVisibility = 'live' | 'pending-review' | 'not-listable';
4240
4245
  /** The result of trying to list a resource on one open index. */
4241
4246
  interface RegisterOutcome {
4242
4247
  source: DiscoverySource;
@@ -4247,6 +4252,14 @@ interface RegisterOutcome {
4247
4252
  detail?: string;
4248
4253
  /** A link to the listing, when the index returns one. */
4249
4254
  listingUrl?: string;
4255
+ /** The lifecycle state of this listing — `'live'`, `'pending-review'`, or
4256
+ * `'not-listable'`. Projected from {@link DIRECTORY_INFO}; branch on this
4257
+ * instead of guessing how soon `discover()` will find the resource. */
4258
+ visibility?: ListingVisibility;
4259
+ /** A one-line, agent-readable caveat for this source (from {@link DIRECTORY_INFO})
4260
+ * — e.g. "402 Index reviews before publishing" or "discover() doesn't read
4261
+ * x402scan, so a live listing there won't appear in discover() results". */
4262
+ note?: string;
4250
4263
  }
4251
4264
  interface SearchOpenIndexesOptions {
4252
4265
  /** Free-text query (filtered client-side against name/description/resource). */
@@ -4278,6 +4291,48 @@ interface RegisterInput {
4278
4291
  */
4279
4292
  attribution?: boolean;
4280
4293
  }
4294
+ /**
4295
+ * Static, agent-readable lifecycle facts about one open index — the SINGLE source
4296
+ * of truth that {@link RegisterOutcome.visibility}/`note` are projected from, and
4297
+ * that an agent can also query directly (via {@link getDirectoryInfo}) to reason
4298
+ * about an index BEFORE calling. Best-effort: an index can change its behaviour,
4299
+ * so treat the timing as guidance, not an SLA.
4300
+ */
4301
+ interface DirectoryInfo {
4302
+ source: DiscoverySource;
4303
+ /** How a new listing is gated: a synchronous URL probe (`402index`, `x402scan`),
4304
+ * or coupled to a facilitator settling a payment (`bazaar`). */
4305
+ review: 'probe-sync' | 'settle-coupled';
4306
+ /** Auth needed to WRITE a listing. */
4307
+ auth: 'none' | 'siwx' | 'facilitator-only';
4308
+ /** Chains (CAIP-2) this index will list. `null` = any chain the resource advertises. */
4309
+ chains: readonly string[] | null;
4310
+ /** Visibility a SUCCESSFUL listing reaches here (the steady state a non-failed
4311
+ * outcome maps to). */
4312
+ onSuccess: ListingVisibility;
4313
+ /** Whether THIS SDK's {@link PipRailClient.discover} reads this index. It reads
4314
+ * `bazaar` + `402index`; it does NOT read `x402scan` — so a live x402scan listing
4315
+ * won't appear in `discover()` results. Don't read that absence as failure. */
4316
+ readByDiscover: boolean;
4317
+ /** One-line caveat: why a register might fail, or what to expect afterwards. */
4318
+ caveat: string;
4319
+ }
4320
+ /**
4321
+ * The open directories' lifecycle, as one queryable map. An agent can branch on
4322
+ * this without embedding directory knowledge: `DIRECTORY_INFO[source].readByDiscover`,
4323
+ * `.chains`, `.onSuccess`, etc. {@link PipRailClient.register} projects the relevant
4324
+ * entry onto every {@link RegisterOutcome} (`visibility` + `note`).
4325
+ */
4326
+ declare const DIRECTORY_INFO: Readonly<Record<DiscoverySource, DirectoryInfo>>;
4327
+ /** Lifecycle facts for one open index (auth, chains, how soon a listing is
4328
+ * findable, whether `discover()` reads it). See {@link DIRECTORY_INFO}. The param
4329
+ * is the closed {@link DiscoverySource} union (TS callers are safe); a string
4330
+ * outside it returns `undefined` at runtime. */
4331
+ declare function getDirectoryInfo(source: DiscoverySource): DirectoryInfo;
4332
+ /** Project the static {@link DIRECTORY_INFO} lifecycle facts onto a register
4333
+ * outcome, so an agent gets `visibility` + `note` in the result it already holds —
4334
+ * no second lookup. A failed outcome is always `'not-listable'`. Idempotent. */
4335
+ declare function decorateOutcome(o: RegisterOutcome): RegisterOutcome;
4281
4336
  /** Normalize an index's network field to CAIP-2 when we recognise the slug;
4282
4337
  * pass a value that's already CAIP-2 (`namespace:reference`) through unchanged.
4283
4338
  * An unknown slug returns unchanged (no `:`), which the client treats as
@@ -4291,8 +4346,11 @@ declare function normalizeNetwork(network: string): string;
4291
4346
  declare function searchOpenIndexes(opts?: SearchOpenIndexesOptions): Promise<DiscoveredResource[]>;
4292
4347
  /**
4293
4348
  * Register a resource on **402 Index** — the primary, friction-free path: a
4294
- * single POST, no auth, no signature, no payment. Searchable within seconds.
4295
- * Returns a structured outcome; never throws for an HTTP/transport problem.
4349
+ * single POST, no auth, no signature, no payment. A self-registered listing is
4350
+ * **pending review** (not searchable until approved verify your domain on
4351
+ * 402index.io for instant approval). Returns a structured outcome; never throws
4352
+ * for an HTTP/transport problem. NOTE: the outcome is BARE — `visibility`/`note`
4353
+ * are added by {@link PipRailClient.register} (or call {@link decorateOutcome}).
4296
4354
  */
4297
4355
  declare function register402Index(input: RegisterInput): Promise<RegisterOutcome>;
4298
4356
  /**
@@ -4300,11 +4358,57 @@ declare function register402Index(input: RegisterInput): Promise<RegisterOutcome
4300
4358
  * EIP-4361 challenge with the merchant's own key, resend with the
4301
4359
  * `SIGN-IN-WITH-X` header. Facilitator-free, but **Base/Solana-only** and EVM
4302
4360
  * signing today. EXPERIMENTAL — the open SIWX handshake is a moving convention;
4303
- * validate against x402scan before relying on it. Never throws.
4361
+ * validate against x402scan before relying on it. Never throws. NOTE: returns a
4362
+ * BARE outcome — `visibility`/`note` are added by {@link PipRailClient.register}
4363
+ * (or call {@link decorateOutcome}).
4304
4364
  */
4305
4365
  declare function registerX402Scan(input: {
4306
4366
  url: string;
4307
4367
  }, signer: DiscoverySigner): Promise<RegisterOutcome>;
4368
+ /** What {@link claim402IndexDomain} returns — the proof to SERVE so 402 Index will
4369
+ * approve your domain (and flip your `pending-review` listings to searchable). */
4370
+ interface DomainClaim {
4371
+ ok: boolean;
4372
+ domain: string;
4373
+ /** Serve THIS string as the entire body of `verificationUrl`. */
4374
+ verificationHash?: string;
4375
+ /** Where to serve it — your `https://<domain>/.well-known/402index-verify.txt`. */
4376
+ verificationUrl?: string;
4377
+ /** 402 Index's own human instructions. */
4378
+ instructions?: string;
4379
+ httpStatus?: number;
4380
+ /** Failure reason when `ok:false`. */
4381
+ detail?: string;
4382
+ }
4383
+ /** What {@link verify402IndexDomain} returns once the proof is in place. */
4384
+ interface DomainVerification {
4385
+ ok: boolean;
4386
+ domain: string;
4387
+ /** 402 Index's status string, e.g. `'verified'`. */
4388
+ status?: string;
4389
+ /** How many of your pending listings were approved by the verification. */
4390
+ servicesCount?: number;
4391
+ httpStatus?: number;
4392
+ detail?: string;
4393
+ }
4394
+ /**
4395
+ * Step 1 of 402 Index domain verification: claim the host of `domainOrUrl`. 402 Index
4396
+ * lists a self-registered resource as PENDING REVIEW; verifying the domain approves it
4397
+ * (and every other pending listing on that domain) so it becomes searchable. Returns the
4398
+ * `verificationHash` to serve as the entire body of `verificationUrl`
4399
+ * (`https://<domain>/.well-known/402index-verify.txt`). Then call {@link verify402IndexDomain}.
4400
+ * No funds move. Never throws.
4401
+ */
4402
+ declare function claim402IndexDomain(domainOrUrl: string, opts?: {
4403
+ contactEmail?: string;
4404
+ }): Promise<DomainClaim>;
4405
+ /**
4406
+ * Step 2 of 402 Index domain verification: after {@link claim402IndexDomain} and serving
4407
+ * the `verificationHash` at `verificationUrl`, tell 402 Index to re-fetch + approve. On
4408
+ * success, the domain's pending listings become searchable (`status:'verified'`,
4409
+ * `servicesCount` approved). No funds move. Never throws.
4410
+ */
4411
+ declare function verify402IndexDomain(domainOrUrl: string): Promise<DomainVerification>;
4308
4412
 
4309
4413
  interface PaymentPolicy {
4310
4414
  /** Per-payment ceiling, human-readable (e.g. '0.10'). Compared using the
@@ -4753,21 +4857,66 @@ declare class PipRailClient {
4753
4857
  *
4754
4858
  * Nothing PipRail-hosted: these are third-party open directories. Never throws
4755
4859
  * for a read problem — an index that's down or changed simply contributes
4756
- * nothing. Honest caveat: index results are cross-scheme (mostly the
4757
- * mainstream `exact` scheme); `fetch()` pays only `onchain-proof` rails
4758
- * directly (pay `exact` resources with the experimental `drivers/evm/exact.ts`).
4860
+ * nothing. Honest caveats (see {@link DIRECTORY_INFO}):
4861
+ * - Reads **`bazaar` + `402index`** only — **NOT `x402scan`** (its reads are paid). A
4862
+ * resource you registered on x402scan is live there but will NOT appear here; don't
4863
+ * read that absence as failure. (Passing `sources:['x402scan']` explicitly yields `[]`.)
4864
+ * - A resource just listed via {@link register} may not appear yet — 402 Index reviews
4865
+ * before publishing, so retry with a brief backoff if a fresh listing is missing.
4866
+ * - Results are cross-scheme (mostly the mainstream `exact` scheme); `fetch()` pays
4867
+ * only `onchain-proof` rails directly (pay `exact` resources with the experimental
4868
+ * `drivers/evm/exact.ts`).
4759
4869
  */
4760
4870
  discover(opts?: DiscoverOptions): Promise<DiscoveredResource[]>;
4761
4871
  /**
4762
4872
  * List a resource you run on the OPEN x402 registries, so agents can find it.
4763
- * Default target is **402 Index** — one POST, no auth, no signature, no payment
4764
- * (searchable within seconds). Add `'x402scan'` to also register via SIWX (one
4765
- * wallet signature; EVM + a Base/Solana rail). Returns one {@link RegisterOutcome}
4766
- * per target — a target the chain can't satisfy comes back `{ ok:false, detail }`,
4767
- * never a throw. An explicit, developer-invoked action; it moves no funds, and
4768
- * nothing is PipRail-hosted — you're listing on third-party open directories.
4873
+ * Default target is **402 Index** — one POST, no auth, no signature, no payment.
4874
+ * Add `'x402scan'` to also register via SIWX (one wallet signature; EVM + a
4875
+ * Base/Solana rail). Returns one {@link RegisterOutcome} per target — a target the
4876
+ * chain can't satisfy comes back `{ ok:false, detail }`, never a throw. An explicit,
4877
+ * developer-invoked action; it moves no funds, and nothing is PipRail-hosted —
4878
+ * you're listing on third-party open directories.
4879
+ *
4880
+ * **Listing is asynchronous — each outcome carries a `visibility` + `note` so an
4881
+ * agent knows when/where the resource is findable (don't assume `ok:true` means
4882
+ * "searchable now"):**
4883
+ * - **402 Index** → `visibility:'pending-review'`. It probes your URL on submit, then lists it
4884
+ * PENDING REVIEW — not searchable until approved (verify your domain on 402index.io for instant
4885
+ * approval), so `discover()` returns nothing for a fresh listing until then. Retry later.
4886
+ * - **x402scan** → `visibility:'live'`, but **`discover()` does NOT read x402scan** — the
4887
+ * listing is real on x402scan.com yet won't show up in `discover()`. Base/Solana only;
4888
+ * needs a resolvable input schema (`/openapi.json` or the `extensions.bazaar` block).
4889
+ * - **Bazaar** → `visibility:'not-listable'` for PipRail (it lists only what its facilitator
4890
+ * settles; PipRail uses none). You can still READ Bazaar via {@link discover} to find others.
4891
+ *
4892
+ * The per-source facts live in {@link DIRECTORY_INFO} (importable) if you'd rather branch
4893
+ * on them before calling.
4769
4894
  */
4770
4895
  register(url: string, opts?: RegisterOptions): Promise<RegisterOutcome[]>;
4896
+ /**
4897
+ * **402 Index domain verification, step 1 of 2.** A self-registered 402 Index
4898
+ * listing is `pending-review` (see {@link register}); verifying your domain flips
4899
+ * it — and every other pending listing on that domain — to APPROVED/searchable.
4900
+ * Pass the resource URL or a bare domain; returns the `verificationHash` to serve
4901
+ * as the entire body of `verificationUrl` (your `/.well-known/402index-verify.txt`).
4902
+ * Then serve it and call {@link verifyDomain}. Moves no funds; never throws.
4903
+ *
4904
+ * ```ts
4905
+ * const claim = await client.claimDomain('https://api.example.com/report')
4906
+ * // serve claim.verificationHash at claim.verificationUrl, then:
4907
+ * const res = await client.verifyDomain('api.example.com') // → { ok:true, status:'verified' }
4908
+ * ```
4909
+ */
4910
+ claimDomain(urlOrDomain: string, opts?: {
4911
+ contactEmail?: string;
4912
+ }): Promise<DomainClaim>;
4913
+ /**
4914
+ * **402 Index domain verification, step 2 of 2.** After {@link claimDomain} and
4915
+ * serving the hash at your `/.well-known/402index-verify.txt`, this tells 402 Index
4916
+ * to re-fetch + approve. On success the domain's pending listings become searchable
4917
+ * (`{ ok:true, status:'verified', servicesCount }`). Moves no funds; never throws.
4918
+ */
4919
+ verifyDomain(urlOrDomain: string): Promise<DomainVerification>;
4771
4920
  /**
4772
4921
  * The discovery signer for the bound wallet (its address + a message signer),
4773
4922
  * or `null` if the chain family doesn't support it (EVM does today). For
@@ -5619,12 +5768,21 @@ declare function buildExactAuthorization(params: BuildExactParams): Promise<{
5619
5768
  authorization: ExactAuthorization;
5620
5769
  signature: Hex;
5621
5770
  }>;
5622
- /** Encode an x402 `exact` PaymentPayload into an `X-PAYMENT` header value. */
5771
+ /**
5772
+ * Encode an x402 `exact` PaymentPayload into an `X-PAYMENT` header value — the
5773
+ * **v1 flat shape** (`{ x402Version, scheme, network, payload }`). This is a
5774
+ * client-side UTILITY (PipRail's own client pays only `onchain-proof`, never this);
5775
+ * the v1 flat shape is what Coinbase's original reference emits and is still accepted
5776
+ * by every x402 gate + facilitator, so `x402Version` defaults to `1` to stay
5777
+ * INTERNALLY CONSISTENT with that shape (emitting `2` here would mislabel a v1 body —
5778
+ * a proper v2 `exact` payload is the nested `accepted`-envelope shape instead). See
5779
+ * the version-posture note in `x402.ts`.
5780
+ */
5623
5781
  declare function encodeXPaymentHeader(input: {
5624
5782
  network: string;
5625
5783
  authorization: ExactAuthorization;
5626
5784
  signature: Hex;
5627
- /** x402 envelope version (Coinbase's reference uses 1). */
5785
+ /** x402 envelope version. Defaults to `1` — consistent with this flat shape. */
5628
5786
  x402Version?: number;
5629
5787
  }): string;
5630
5788
  /**
@@ -5740,4 +5898,4 @@ declare function readExactDomain(publicClient: PublicClient, asset: string): Pro
5740
5898
  version: string;
5741
5899
  } | null>;
5742
5900
 
5743
- export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExactAuthorizationWire, type ExactPaymentPayload, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, GENERATOR, HEADER_REQUIRED, HEADER_RESPONSE, HEADER_RESPONSE_V1, HEADER_SIGNATURE, HEADER_SIGNATURE_V1, InsufficientFundsError, InvalidEnvelopeError, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type ParsedExactPayment, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SettleViaFacilitatorInput, SettlementError, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402AnyAccept, type X402Challenge, type X402DnsRecord, type X402ExactAcceptEntry, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, createPaymentGate, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, normalizeNetwork, parseChallenge, parseExactPaymentHeader, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, readExactDomain, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, settleViaFacilitator, toInsufficientFundsError, toInvalidBody };
5901
+ export { type AcceptOption, type AddressId, type AgentTool, type AlgorandToken, type AptosToken, type AssetId, type BuildExactParams, CHAINS, type Caip2, type ChainFamily, type ChainInput, type ChainName, type ChainPreset, type ChainSelector, type ConfirmInfo, ConfirmationTimeoutError, type CostEstimate, DIRECTORY_INFO, type DirectoryInfo, type DiscoverOptions, type DiscoveredRail, type DiscoveredResource, type DiscoverySigner, type DiscoverySource, type DomainClaim, type DomainVerification, EIP3009_TYPES, EXACT_NETWORK_SLUGS, type EvmToken, type ExactAccept, type ExactAuthorization, type ExactAuthorizationWire, type ExactPaymentPayload, type ExactRailOption, type ExpressLikeMiddleware, type ExpressLikeNext, type ExpressLikeRequest, type ExpressLikeResponse, type FacilitatorConfig, type FacilitatorPaymentRequirements, GENERATOR, HEADER_REQUIRED, HEADER_RESPONSE, HEADER_RESPONSE_V1, HEADER_SIGNATURE, HEADER_SIGNATURE_V1, InsufficientFundsError, InvalidEnvelopeError, type ListingVisibility, type ManifestInput, MaxRetriesExceededError, MissingDriverError, type NearToken, NoCompatibleAcceptError, NonReplayableBodyError, type OpenApiDocument, type OpenApiOperation, type ParsedExactPayment, type PayBlocker, type PayOption, type PayWarning, PaymentDeclinedError, type PaymentDriver, type PaymentGate, type PaymentIntent, type PaymentPlan, type PaymentPolicy, type PaymentRail, PaymentTimeoutError, PipRailClient, type PipRailClientOptions, type PipRailCostQuote, PipRailError, type PipRailEvent, type PipRailQuote, type PolicyDecision, RecipientNotReadyError, type RecipientReason, type RegisterInput, type RegisterOptions, type RegisterOutcome, type RequirePaymentOptions, type ResolveOptions, type ResolvedChain, type ResolvedNetwork, type ResolvedToken, type ResourceDescription, type SearchOpenIndexesOptions, type SettleViaFacilitatorInput, SettlementError, type SolanaToken, type SpendAssetTotal, type SpendRecord, type SpendSummary, type StellarToken, type SuiToken, type TokenInfo, type TokenInput, type TonToken, type ToolAnnotations, type TronToken, UnknownTokenError, UnsupportedNetworkError, type VerifyErrorCode, type VerifyPaymentResult, type VerifyResult, type WalletBalance, type WalletHandle, type WalletInput, type WellKnownX402, WrongChainError, WrongFamilyError, type X402AcceptEntry, type X402AnyAccept, type X402Challenge, type X402DnsRecord, type X402ExactAcceptEntry, type X402InvalidBody, type X402PaymentSignature, type X402Receipt, type X402ResourceObject, type XrplToken, buildChallengeHeader, buildExactAuthorization, buildOpenApi, buildReceiptHeader, buildSignatureHeader, buildWellKnownX402, buildX402DnsTxt, chainIdForExactNetwork, claim402IndexDomain, createPaymentGate, decorateOutcome, eip3009Abi, encodeXPaymentHeader, evaluatePolicy, getDirectoryInfo, normalizeNetwork, parseChallenge, parseExactPaymentHeader, parseExactRequirements, parseReceipt, parseSignatureHeader, paymentTools, pickAccept, planAcross, readExactDomain, register402Index, registerDriver, registerX402Scan, requirePayment, resolveChain, searchOpenIndexes, settleViaFacilitator, toInsufficientFundsError, toInvalidBody, verify402IndexDomain };