Sign In

payagent

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

payagent - npm Package Compare versions

Comparing version
2.16.0
to
2.17.0
+57
-1
dist/index.d.ts

@@ -1419,2 +1419,58 @@ import { b as PayFetchFn } from './fetch-local-CjNSDxFt.js';

export { type AgentSummary, type AgfacFlatRequirements, type AttachWalletOptions, type BalanceResponse, type BootstrapAgentConfig, type BootstrapAgentResult, BootstrapError, type BootstrapExistingAgent, type BootstrapPairing, type CardSetupSessionResponse, type CardSetupStatus, type CardSetupStatusResponse, type CatalogResource, type CreateEndUserOptions, type CreatePaymentOptions, type CreateX402AgentResponse, DEFAULT_ARISPAY_URL, DelegationClient, DeviceCodeError, type DeviceCodeResponse, type DeviceTokenResponse, type DiscoverCandidate, type DiscoverCatalogOptions, type DiscoverCategory, type DiscoverEndpoint, type DiscoverInput, type DiscoverOptions, type DiscoverPricing, type DiscoverResult, type DiscoverSource, type DiscoverTransport, type EndUserResponse, HostedTopupNotConfiguredError, type HostedTopupOptions, type HostedTopupResponse, type InspectChallengeOptions, type InspectChallengeResult, InspectParseError, type InspectedAccept, InvalidRequirementsError, type LaunchAgentConfig, type LaunchedAgent, type ListAgentsOptions, type ListAgentsResponse, MissingArisPayApiKeyError, MissingDevKeyForSyncError, PayAgentError, PayFetchFn, type PaymentFeedItem, type PaymentNextAction, type PaymentRail, type PaymentReceipt, PaymentRejectedError, type PaymentRequirementsBody, type PaymentResponse, type PaymentSpendInfo, type PaymentStatus, type PaymentsFeedQueryOptions, type PaymentsFeedResponse, type RenameAgentResponse, type SetUserLimitsOptions, type SpendLimitResponse, type StoredAgent, type StoredConfig, type SyncAgentsOptions, type SyncAgentsResult, type SyncedAgent, USDC_CONTRACTS, type UpdateAgentPatch, type UpdateAgentResponse, type WalletChain, type WalletPaymentMethodResponse, type WalletStatusResponse, type X402Accept, type X402AgentConfig, type X402Requirements, bootstrapAgent, centsFromBaseUnits, clearApiKey, discover, discoverCatalog, formatUSDC, getAgent, getApiKey, getArispayUrl, getConfigPath, getLaunchedAgent, getUSDCBalance, inspectChallenge, launchAgent, listAgents, loadConfig, pollDeviceToken, removeAgent, renameStoredAgent, requestDeviceCode, runDeviceAuth, saveAgent, saveConfig, setApiKey, syncAgents, upsertManyFromServer };
/**
* Rail-agnostic payment handshake seam (M2M Session 6, constraint 5).
* Spec: docs/specs/handshake-abstraction-v1.md.
*
* The four-stage handshake (payment-required → terms → authorization →
* delivery) is rail-agnostic; only stage 3 (authorization) is backend-
* specific. This module defines the backend interface and registers the
* LIVE x402 (permissionless crypto, Lane P) backend plus a SPECCED-not-built
* mandate-card backend stub. The existing x402 code paths (`payFetchLocal`,
* `payFetchDelegated`) are UNCHANGED — the x402 backend here is a thin
* descriptor over them, not a reimplementation.
*/
interface HandshakeTerms {
/** Which backend can satisfy these terms. */
backend: string;
scheme: string;
network?: string;
asset?: string;
amountBaseUnits?: string;
payTo?: string;
[key: string]: unknown;
}
interface PaymentAuthorization {
headerName: string;
headerValue: string;
backend: string;
}
interface PaymentBackend {
id: string;
supports(terms: HandshakeTerms): boolean;
authorize(terms: HandshakeTerms): Promise<PaymentAuthorization>;
}
declare class BackendNotImplementedError extends Error {
code: "NOT_IMPLEMENTED";
constructor(backend: string);
}
/**
* x402 permissionless crypto backend (LIVE, Lane P). A descriptor: it
* declares support for exact-scheme crypto terms. Actual authorization runs
* through the unchanged `payFetchLocal` / `payFetchDelegated` fetch wrappers
* — this backend does not re-sign; callers using the fetch wrappers already
* get stage 3+4 for free. `authorize` is provided for callers that drive the
* handshake manually via an injected signer.
*/
declare function makeX402Backend(sign: (terms: HandshakeTerms) => Promise<string>): PaymentBackend;
/**
* mandate-card backend (SPECCED, NOT BUILT — post-Gate-0). Ships as a stub
* that declares its terms shape and throws on authorize. Do NOT implement
* here; its mechanism is a follow-on session gated on a concluded rail
* contract (docs/specs/handshake-abstraction-v1.md).
*/
declare const mandateCardBackend: PaymentBackend;
/** Select the backend that satisfies the terms. Ambiguity is a hard error —
* never a silent fallback that could pay on the wrong rail. */
declare function selectBackend(terms: HandshakeTerms, backends: PaymentBackend[]): PaymentBackend;
export { type AgentSummary, type AgfacFlatRequirements, type AttachWalletOptions, BackendNotImplementedError, type BalanceResponse, type BootstrapAgentConfig, type BootstrapAgentResult, BootstrapError, type BootstrapExistingAgent, type BootstrapPairing, type CardSetupSessionResponse, type CardSetupStatus, type CardSetupStatusResponse, type CatalogResource, type CreateEndUserOptions, type CreatePaymentOptions, type CreateX402AgentResponse, DEFAULT_ARISPAY_URL, DelegationClient, DeviceCodeError, type DeviceCodeResponse, type DeviceTokenResponse, type DiscoverCandidate, type DiscoverCatalogOptions, type DiscoverCategory, type DiscoverEndpoint, type DiscoverInput, type DiscoverOptions, type DiscoverPricing, type DiscoverResult, type DiscoverSource, type DiscoverTransport, type EndUserResponse, type HandshakeTerms, HostedTopupNotConfiguredError, type HostedTopupOptions, type HostedTopupResponse, type InspectChallengeOptions, type InspectChallengeResult, InspectParseError, type InspectedAccept, InvalidRequirementsError, type LaunchAgentConfig, type LaunchedAgent, type ListAgentsOptions, type ListAgentsResponse, MissingArisPayApiKeyError, MissingDevKeyForSyncError, PayAgentError, PayFetchFn, type PaymentAuthorization, type PaymentBackend, type PaymentFeedItem, type PaymentNextAction, type PaymentRail, type PaymentReceipt, PaymentRejectedError, type PaymentRequirementsBody, type PaymentResponse, type PaymentSpendInfo, type PaymentStatus, type PaymentsFeedQueryOptions, type PaymentsFeedResponse, type RenameAgentResponse, type SetUserLimitsOptions, type SpendLimitResponse, type StoredAgent, type StoredConfig, type SyncAgentsOptions, type SyncAgentsResult, type SyncedAgent, USDC_CONTRACTS, type UpdateAgentPatch, type UpdateAgentResponse, type WalletChain, type WalletPaymentMethodResponse, type WalletStatusResponse, type X402Accept, type X402AgentConfig, type X402Requirements, bootstrapAgent, centsFromBaseUnits, clearApiKey, discover, discoverCatalog, formatUSDC, getAgent, getApiKey, getArispayUrl, getConfigPath, getLaunchedAgent, getUSDCBalance, inspectChallenge, launchAgent, listAgents, loadConfig, makeX402Backend, mandateCardBackend, pollDeviceToken, removeAgent, renameStoredAgent, requestDeviceCode, runDeviceAuth, saveAgent, saveConfig, selectBackend, setApiKey, syncAgents, upsertManyFromServer };

@@ -45,3 +45,41 @@ import {

} from "./chunk-5DDTY352.js";
// src/handshake.ts
var BackendNotImplementedError = class extends Error {
code = "NOT_IMPLEMENTED";
constructor(backend) {
super(`payment backend "${backend}" is specced but not implemented`);
this.name = "BackendNotImplementedError";
}
};
function makeX402Backend(sign) {
return {
id: "x402",
supports: (terms) => terms.backend === "x402" || terms.scheme === "exact" && typeof terms.network === "string" && terms.network.startsWith("eip155:"),
authorize: async (terms) => ({
headerName: "X-PAYMENT",
headerValue: await sign(terms),
backend: "x402"
})
};
}
var mandateCardBackend = {
id: "mandate-card",
supports: (terms) => terms.backend === "mandate-card",
authorize: async () => {
throw new BackendNotImplementedError("mandate-card");
}
};
function selectBackend(terms, backends) {
const matches = backends.filter((b) => b.supports(terms));
if (matches.length === 0) {
throw new Error(`no payment backend supports these terms (backend="${terms.backend}", scheme="${terms.scheme}")`);
}
if (matches.length > 1) {
throw new Error(`ambiguous terms \u2014 ${matches.length} backends match; set terms.backend explicitly`);
}
return matches[0];
}
export {
BackendNotImplementedError,
BootstrapError,

@@ -75,2 +113,4 @@ DEFAULT_ARISPAY_URL,

loadConfig,
makeX402Backend,
mandateCardBackend,
payFetchDelegated,

@@ -85,2 +125,3 @@ payFetchLocal,

saveConfig,
selectBackend,
setApiKey,

@@ -87,0 +128,0 @@ syncAgents,

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
{"version":3,"sources":["../src/handshake.ts"],"sourcesContent":["/**\n * Rail-agnostic payment handshake seam (M2M Session 6, constraint 5).\n * Spec: docs/specs/handshake-abstraction-v1.md.\n *\n * The four-stage handshake (payment-required → terms → authorization →\n * delivery) is rail-agnostic; only stage 3 (authorization) is backend-\n * specific. This module defines the backend interface and registers the\n * LIVE x402 (permissionless crypto, Lane P) backend plus a SPECCED-not-built\n * mandate-card backend stub. The existing x402 code paths (`payFetchLocal`,\n * `payFetchDelegated`) are UNCHANGED — the x402 backend here is a thin\n * descriptor over them, not a reimplementation.\n */\n\nexport interface HandshakeTerms {\n /** Which backend can satisfy these terms. */\n backend: string;\n scheme: string;\n network?: string;\n asset?: string;\n amountBaseUnits?: string;\n payTo?: string;\n // mandate-card backend (future) adds: mandateId, currency, amountCents, merchantRef.\n [key: string]: unknown;\n}\n\nexport interface PaymentAuthorization {\n headerName: string;\n headerValue: string;\n backend: string;\n}\n\nexport interface PaymentBackend {\n id: string;\n supports(terms: HandshakeTerms): boolean;\n authorize(terms: HandshakeTerms): Promise<PaymentAuthorization>;\n}\n\nexport class BackendNotImplementedError extends Error {\n code = \"NOT_IMPLEMENTED\" as const;\n constructor(backend: string) {\n super(`payment backend \"${backend}\" is specced but not implemented`);\n this.name = \"BackendNotImplementedError\";\n }\n}\n\n/**\n * x402 permissionless crypto backend (LIVE, Lane P). A descriptor: it\n * declares support for exact-scheme crypto terms. Actual authorization runs\n * through the unchanged `payFetchLocal` / `payFetchDelegated` fetch wrappers\n * — this backend does not re-sign; callers using the fetch wrappers already\n * get stage 3+4 for free. `authorize` is provided for callers that drive the\n * handshake manually via an injected signer.\n */\nexport function makeX402Backend(\n sign: (terms: HandshakeTerms) => Promise<string>,\n): PaymentBackend {\n return {\n id: \"x402\",\n supports: (terms) =>\n terms.backend === \"x402\" ||\n (terms.scheme === \"exact\" && typeof terms.network === \"string\" && terms.network.startsWith(\"eip155:\")),\n authorize: async (terms) => ({\n headerName: \"X-PAYMENT\",\n headerValue: await sign(terms),\n backend: \"x402\",\n }),\n };\n}\n\n/**\n * mandate-card backend (SPECCED, NOT BUILT — post-Gate-0). Ships as a stub\n * that declares its terms shape and throws on authorize. Do NOT implement\n * here; its mechanism is a follow-on session gated on a concluded rail\n * contract (docs/specs/handshake-abstraction-v1.md).\n */\nexport const mandateCardBackend: PaymentBackend = {\n id: \"mandate-card\",\n supports: (terms) => terms.backend === \"mandate-card\",\n authorize: async () => {\n throw new BackendNotImplementedError(\"mandate-card\");\n },\n};\n\n/** Select the backend that satisfies the terms. Ambiguity is a hard error —\n * never a silent fallback that could pay on the wrong rail. */\nexport function selectBackend(\n terms: HandshakeTerms,\n backends: PaymentBackend[],\n): PaymentBackend {\n const matches = backends.filter((b) => b.supports(terms));\n if (matches.length === 0) {\n throw new Error(`no payment backend supports these terms (backend=\"${terms.backend}\", scheme=\"${terms.scheme}\")`);\n }\n if (matches.length > 1) {\n throw new Error(`ambiguous terms — ${matches.length} backends match; set terms.backend explicitly`);\n }\n return matches[0]!;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,IAAM,6BAAN,cAAyC,MAAM;AAAA,EACpD,OAAO;AAAA,EACP,YAAY,SAAiB;AAC3B,UAAM,oBAAoB,OAAO,kCAAkC;AACnE,SAAK,OAAO;AAAA,EACd;AACF;AAUO,SAAS,gBACd,MACgB;AAChB,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,UAAU,CAAC,UACT,MAAM,YAAY,UACjB,MAAM,WAAW,WAAW,OAAO,MAAM,YAAY,YAAY,MAAM,QAAQ,WAAW,SAAS;AAAA,IACtG,WAAW,OAAO,WAAW;AAAA,MAC3B,YAAY;AAAA,MACZ,aAAa,MAAM,KAAK,KAAK;AAAA,MAC7B,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAQO,IAAM,qBAAqC;AAAA,EAChD,IAAI;AAAA,EACJ,UAAU,CAAC,UAAU,MAAM,YAAY;AAAA,EACvC,WAAW,YAAY;AACrB,UAAM,IAAI,2BAA2B,cAAc;AAAA,EACrD;AACF;AAIO,SAAS,cACd,OACA,UACgB;AAChB,QAAM,UAAU,SAAS,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,CAAC;AACxD,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI,MAAM,qDAAqD,MAAM,OAAO,cAAc,MAAM,MAAM,IAAI;AAAA,EAClH;AACA,MAAI,QAAQ,SAAS,GAAG;AACtB,UAAM,IAAI,MAAM,0BAAqB,QAAQ,MAAM,+CAA+C;AAAA,EACpG;AACA,SAAO,QAAQ,CAAC;AAClB;","names":[]}

@@ -36,4 +36,4 @@ import { DynamicStructuredTool } from '@langchain/core/tools';

}, "strip", z.ZodTypeAny, {
method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH";
url: string;
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
headers?: Record<string, string> | undefined;

@@ -43,8 +43,8 @@ body?: string | undefined;

url: string;
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | undefined;
headers?: Record<string, string> | undefined;
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | undefined;
body?: string | undefined;
}>, {
method: "POST" | "GET" | "PUT" | "DELETE" | "PATCH";
url: string;
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
headers?: Record<string, string> | undefined;

@@ -54,4 +54,4 @@ body?: string | undefined;

url: string;
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | undefined;
headers?: Record<string, string> | undefined;
method?: "POST" | "GET" | "PUT" | "DELETE" | "PATCH" | undefined;
body?: string | undefined;

@@ -58,0 +58,0 @@ }, string, unknown, "pay_api">;

@@ -31,4 +31,4 @@ import { Tool } from 'ai';

method: z.ZodDefault<z.ZodEnum<{
GET: "GET";
POST: "POST";
GET: "GET";
PUT: "PUT";

@@ -35,0 +35,0 @@ DELETE: "DELETE";

{
"name": "payagent",
"version": "2.16.0",
"version": "2.17.0",
"description": "Let AI agents pay for APIs. The ArisPay SDK + CLI for x402 payments with delegated-custody wallets — no private keys in your process.",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is too big to display