@asgcard/sdk 1.0.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/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # @asgcard/sdk
2
+
3
+ TypeScript SDK for [ASG Card](https://asgcard.dev) — instant virtual Visa cards for AI agents, paid via x402 on Stellar.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @asgcard/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { ASGCardClient } from '@asgcard/sdk';
15
+
16
+ const client = new ASGCardClient({
17
+ privateKey: 'S...', // Stellar secret key
18
+ });
19
+
20
+ // Create a $10 virtual card
21
+ const result = await client.createCard({
22
+ amount: 10,
23
+ nameOnCard: 'AI AGENT',
24
+ email: 'agent@example.com',
25
+ });
26
+
27
+ console.log(result.card.cardId); // card_xxxx
28
+ console.log(result.detailsEnvelope); // { cardNumber, cvv, expiry, ... }
29
+ console.log(result.payment.txHash); // Stellar tx hash
30
+ ```
31
+
32
+ ## How It Works
33
+
34
+ 1. SDK calls `POST /cards/create/tier/10`
35
+ 2. API returns `402` with x402 payment challenge
36
+ 3. SDK builds a Soroban USDC transfer, signs it, and retries with `X-PAYMENT` header
37
+ 4. API verifies + settles on Stellar mainnet → returns `201` with card details
38
+
39
+ ## API
40
+
41
+ ### `new ASGCardClient(config)`
42
+
43
+ | Option | Type | Default | Description |
44
+ |--------|------|---------|-------------|
45
+ | `privateKey` | `string` | — | Stellar secret key (`S...`) |
46
+ | `walletAdapter` | `WalletAdapter` | — | External wallet (browser extension) |
47
+ | `baseUrl` | `string` | `https://api.asgcard.dev` | API URL |
48
+ | `rpcUrl` | `string` | `https://mainnet.sorobanrpc.com` | Soroban RPC |
49
+ | `timeout` | `number` | `60000` | Request timeout (ms) |
50
+
51
+ ### `client.createCard(params)`
52
+
53
+ ```typescript
54
+ const card = await client.createCard({
55
+ amount: 10, // 10, 25, 50, 100, 200, or 500 USD
56
+ nameOnCard: 'MY AGENT',
57
+ email: 'agent@example.com',
58
+ });
59
+ ```
60
+
61
+ ### `client.fundCard(params)`
62
+
63
+ ```typescript
64
+ const funded = await client.fundCard({
65
+ amount: 25,
66
+ cardId: 'card_xxxx',
67
+ });
68
+ ```
69
+
70
+ ### `client.getTiers()`
71
+
72
+ ```typescript
73
+ const tiers = await client.getTiers();
74
+ // { creation: [...], funding: [...] }
75
+ ```
76
+
77
+ ### `client.health()`
78
+
79
+ ```typescript
80
+ const health = await client.health();
81
+ // { status: 'ok', version: '0.3.1' }
82
+ ```
83
+
84
+ ## Low-Level Utilities
85
+
86
+ For custom integrations:
87
+
88
+ ```typescript
89
+ import {
90
+ parseChallenge,
91
+ buildPaymentTransaction,
92
+ buildPaymentPayload,
93
+ handleX402Payment,
94
+ } from '@asgcard/sdk';
95
+ ```
96
+
97
+ ## Requirements
98
+
99
+ - Node.js 18+
100
+ - Stellar account with USDC balance
101
+ - USDC asset: `CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75` (Soroban SAC)
102
+
103
+ ## Links
104
+
105
+ - [Documentation](https://asgcard.dev/docs)
106
+ - [OpenAPI Spec](https://asgcard.dev/openapi.json)
107
+ - [API Status](https://api.asgcard.dev/health)
108
+
109
+ ## License
110
+
111
+ MIT
@@ -0,0 +1,29 @@
1
+ import type { ASGCardClientConfig, CardResult, CreateCardParams, FundCardParams, FundResult, HealthResponse, TierResponse } from "./types";
2
+ export declare class ASGCardClient {
3
+ private readonly baseUrl;
4
+ private readonly timeout;
5
+ private readonly rpcServer;
6
+ private readonly keypair?;
7
+ private readonly walletAdapter?;
8
+ constructor(config: ASGCardClientConfig);
9
+ /** Stellar public key (G...) */
10
+ get address(): string;
11
+ /**
12
+ * Create a virtual card for a supported tier amount.
13
+ * Handles 402 → x402 payment → 201 automatically.
14
+ */
15
+ createCard(params: CreateCardParams): Promise<CardResult>;
16
+ /**
17
+ * Fund an existing card by tier amount.
18
+ * Handles 402 → x402 payment → 200 automatically.
19
+ */
20
+ fundCard(params: FundCardParams): Promise<FundResult>;
21
+ /** Get available create/fund tier amounts and pricing */
22
+ getTiers(): Promise<TierResponse>;
23
+ /** Health check */
24
+ health(): Promise<HealthResponse>;
25
+ private requestWithX402;
26
+ private request;
27
+ private rawFetch;
28
+ private parseResponse;
29
+ }
package/dist/client.js ADDED
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ASGCardClient = void 0;
4
+ /**
5
+ * @asgcard/sdk — ASGCardClient
6
+ *
7
+ * Main client for the ASG Card API.
8
+ * Handles x402 payment flow on Stellar automatically.
9
+ */
10
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
11
+ const errors_1 = require("./errors");
12
+ const x402_1 = require("./utils/x402");
13
+ const DEFAULT_BASE_URL = "https://api.asgcard.dev";
14
+ const DEFAULT_RPC_URL = "https://mainnet.sorobanrpc.com";
15
+ const DEFAULT_TIMEOUT = 60_000;
16
+ class ASGCardClient {
17
+ baseUrl;
18
+ timeout;
19
+ rpcServer;
20
+ keypair;
21
+ walletAdapter;
22
+ constructor(config) {
23
+ if (!config.privateKey && !config.walletAdapter) {
24
+ throw new Error("Provide either privateKey or walletAdapter");
25
+ }
26
+ this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
27
+ this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
28
+ this.rpcServer = new stellar_sdk_1.rpc.Server(config.rpcUrl ?? DEFAULT_RPC_URL);
29
+ if (config.privateKey) {
30
+ this.keypair = stellar_sdk_1.Keypair.fromSecret(config.privateKey);
31
+ }
32
+ this.walletAdapter = config.walletAdapter;
33
+ }
34
+ /** Stellar public key (G...) */
35
+ get address() {
36
+ if (this.keypair) {
37
+ return this.keypair.publicKey();
38
+ }
39
+ return this.walletAdapter.publicKey;
40
+ }
41
+ /**
42
+ * Create a virtual card for a supported tier amount.
43
+ * Handles 402 → x402 payment → 201 automatically.
44
+ */
45
+ async createCard(params) {
46
+ return this.requestWithX402(`/cards/create/tier/${params.amount}`, {
47
+ method: "POST",
48
+ body: JSON.stringify({
49
+ nameOnCard: params.nameOnCard,
50
+ email: params.email
51
+ })
52
+ });
53
+ }
54
+ /**
55
+ * Fund an existing card by tier amount.
56
+ * Handles 402 → x402 payment → 200 automatically.
57
+ */
58
+ async fundCard(params) {
59
+ return this.requestWithX402(`/cards/fund/tier/${params.amount}`, {
60
+ method: "POST",
61
+ body: JSON.stringify({ cardId: params.cardId })
62
+ });
63
+ }
64
+ /** Get available create/fund tier amounts and pricing */
65
+ async getTiers() {
66
+ return this.request("/cards/tiers", { method: "GET" });
67
+ }
68
+ /** Health check */
69
+ async health() {
70
+ return this.request("/health", { method: "GET" });
71
+ }
72
+ // ── x402 payment flow ────────────────────────────────
73
+ async requestWithX402(path, init) {
74
+ const first = await this.rawFetch(path, init);
75
+ if (first.status !== 402) {
76
+ return this.parseResponse(first);
77
+ }
78
+ const challengePayload = await first.json();
79
+ const paymentHeader = await (0, x402_1.handleX402Payment)({
80
+ rpcServer: this.rpcServer,
81
+ challengePayload,
82
+ keypair: this.keypair,
83
+ walletAdapter: this.walletAdapter
84
+ });
85
+ const retry = await this.rawFetch(path, {
86
+ ...init,
87
+ headers: {
88
+ "Content-Type": "application/json",
89
+ "X-PAYMENT": paymentHeader,
90
+ ...(init.headers ?? {})
91
+ }
92
+ });
93
+ return this.parseResponse(retry);
94
+ }
95
+ // ── HTTP primitives ──────────────────────────────────
96
+ async request(path, init) {
97
+ const response = await this.rawFetch(path, init);
98
+ return this.parseResponse(response);
99
+ }
100
+ async rawFetch(path, init) {
101
+ const controller = new AbortController();
102
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
103
+ try {
104
+ return await fetch(`${this.baseUrl}${path}`, {
105
+ ...init,
106
+ headers: {
107
+ "Content-Type": "application/json",
108
+ ...(init.headers ?? {})
109
+ },
110
+ signal: controller.signal
111
+ });
112
+ }
113
+ catch (error) {
114
+ if (error instanceof Error && error.name === "AbortError") {
115
+ throw new errors_1.TimeoutError();
116
+ }
117
+ throw error;
118
+ }
119
+ finally {
120
+ clearTimeout(timeoutId);
121
+ }
122
+ }
123
+ async parseResponse(response) {
124
+ const payload = await response.json().catch(() => ({}));
125
+ if (!response.ok) {
126
+ throw new errors_1.ApiError(response.status, payload);
127
+ }
128
+ return payload;
129
+ }
130
+ }
131
+ exports.ASGCardClient = ASGCardClient;
132
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,sDAAkE;AAClE,qCAAkD;AAWlD,uCAAiD;AAEjD,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AACnD,MAAM,eAAe,GAAG,gCAAgC,CAAC;AACzD,MAAM,eAAe,GAAG,MAAM,CAAC;AAE/B,MAAa,aAAa;IACP,OAAO,CAAS;IAEhB,OAAO,CAAS;IAEhB,SAAS,CAAoB;IAE7B,OAAO,CAAW;IAElB,aAAa,CAAiB;IAE/C,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,gBAAgB,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,eAAe,CAAC,CAAC;QAEzE,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,GAAG,qBAAO,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,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3C,GAAG,IAAI;gBACP,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;iBACxB;gBACD,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1D,MAAM,IAAI,qBAAY,EAAE,CAAC;YAC3B,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CAAI,QAAkB;QAC/C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAExD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,iBAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,OAAY,CAAC;IACtB,CAAC;CACF;AA7ID,sCA6IC"}
@@ -0,0 +1,17 @@
1
+ export declare class ApiError extends Error {
2
+ readonly status: number;
3
+ readonly body: unknown;
4
+ constructor(status: number, body: unknown);
5
+ }
6
+ export declare class TimeoutError extends Error {
7
+ constructor(message?: string);
8
+ }
9
+ export declare class PaymentError extends Error {
10
+ readonly txHash?: string;
11
+ constructor(message: string, txHash?: string);
12
+ }
13
+ export declare class InsufficientBalanceError extends Error {
14
+ readonly required: string;
15
+ readonly available: string;
16
+ constructor(required: string, available: string);
17
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InsufficientBalanceError = exports.PaymentError = exports.TimeoutError = exports.ApiError = void 0;
4
+ class ApiError extends Error {
5
+ status;
6
+ body;
7
+ constructor(status, body) {
8
+ super(`API error ${status}`);
9
+ this.status = status;
10
+ this.body = body;
11
+ }
12
+ }
13
+ exports.ApiError = ApiError;
14
+ class TimeoutError extends Error {
15
+ constructor(message = "Request timed out") {
16
+ super(message);
17
+ }
18
+ }
19
+ exports.TimeoutError = TimeoutError;
20
+ class PaymentError extends Error {
21
+ txHash;
22
+ constructor(message, txHash) {
23
+ super(message);
24
+ this.txHash = txHash;
25
+ }
26
+ }
27
+ exports.PaymentError = PaymentError;
28
+ class InsufficientBalanceError extends Error {
29
+ required;
30
+ available;
31
+ constructor(required, available) {
32
+ super(`Insufficient USDC balance. Required: ${required}, available: ${available}`);
33
+ this.required = required;
34
+ this.available = available;
35
+ }
36
+ }
37
+ exports.InsufficientBalanceError = InsufficientBalanceError;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAS;IAEf,IAAI,CAAU;IAEvB,YAAY,MAAc,EAAE,IAAa;QACvC,KAAK,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAVD,4BAUC;AAED,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAO,GAAG,mBAAmB;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,oCAIC;AAED,MAAa,YAAa,SAAQ,KAAK;IAC5B,MAAM,CAAU;IAEzB,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAPD,oCAOC;AAED,MAAa,wBAAyB,SAAQ,KAAK;IACxC,QAAQ,CAAS;IAEjB,SAAS,CAAS;IAE3B,YAAY,QAAgB,EAAE,SAAiB;QAC7C,KAAK,CAAC,wCAAwC,QAAQ,gBAAgB,SAAS,EAAE,CAAC,CAAC;QACnF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAVD,4DAUC"}
@@ -0,0 +1,4 @@
1
+ export { ASGCardClient } from "./client";
2
+ export { ApiError, TimeoutError, PaymentError, InsufficientBalanceError } from "./errors";
3
+ export type { ASGCardClientConfig, WalletAdapter, CreateCardParams, FundCardParams, TierResponse, TierEntry, CardResult, FundResult, HealthResponse, BillingAddress, SensitiveCardDetails, X402Challenge, X402Accept, X402PaymentPayload } from "./types";
4
+ export { parseChallenge, checkBalance, executePayment, buildPaymentPayload, buildPaymentTransaction, handleX402Payment } from "./utils/x402";
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleX402Payment = exports.buildPaymentTransaction = exports.buildPaymentPayload = exports.executePayment = exports.checkBalance = exports.parseChallenge = exports.InsufficientBalanceError = exports.PaymentError = exports.TimeoutError = exports.ApiError = exports.ASGCardClient = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "ASGCardClient", { enumerable: true, get: function () { return client_1.ASGCardClient; } });
6
+ var errors_1 = require("./errors");
7
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return errors_1.ApiError; } });
8
+ Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
9
+ Object.defineProperty(exports, "PaymentError", { enumerable: true, get: function () { return errors_1.PaymentError; } });
10
+ Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return errors_1.InsufficientBalanceError; } });
11
+ var x402_1 = require("./utils/x402");
12
+ Object.defineProperty(exports, "parseChallenge", { enumerable: true, get: function () { return x402_1.parseChallenge; } });
13
+ Object.defineProperty(exports, "checkBalance", { enumerable: true, get: function () { return x402_1.checkBalance; } });
14
+ Object.defineProperty(exports, "executePayment", { enumerable: true, get: function () { return x402_1.executePayment; } });
15
+ Object.defineProperty(exports, "buildPaymentPayload", { enumerable: true, get: function () { return x402_1.buildPaymentPayload; } });
16
+ Object.defineProperty(exports, "buildPaymentTransaction", { enumerable: true, get: function () { return x402_1.buildPaymentTransaction; } });
17
+ Object.defineProperty(exports, "handleX402Payment", { enumerable: true, get: function () { return x402_1.handleX402Payment; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AAEtB,mCAKkB;AAJhB,kGAAA,QAAQ,OAAA;AACR,sGAAA,YAAY,OAAA;AACZ,sGAAA,YAAY,OAAA;AACZ,kHAAA,wBAAwB,OAAA;AAoB1B,qCAOsB;AANpB,sGAAA,cAAc,OAAA;AACd,oGAAA,YAAY,OAAA;AACZ,sGAAA,cAAc,OAAA;AACd,2GAAA,mBAAmB,OAAA;AACnB,+GAAA,uBAAuB,OAAA;AACvB,yGAAA,iBAAiB,OAAA"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * @asgcard/sdk — type definitions
3
+ * x402 payment protocol on Stellar (Soroban SAC USDC)
4
+ */
5
+ /** Adapter for external wallet signing (e.g. browser extension) */
6
+ export interface WalletAdapter {
7
+ /** Stellar public key (G...) */
8
+ publicKey: string;
9
+ /** Sign a Stellar XDR transaction envelope, return signed XDR */
10
+ signTransaction(transactionXDR: string, networkPassphrase: string): Promise<string>;
11
+ }
12
+ export interface ASGCardClientConfig {
13
+ /** Stellar secret key (S...) — provide either this or walletAdapter */
14
+ privateKey?: string;
15
+ /** External wallet adapter — provide either this or privateKey */
16
+ walletAdapter?: WalletAdapter;
17
+ /** API base URL (default: https://api.asgcard.dev) */
18
+ baseUrl?: string;
19
+ /** Soroban RPC URL (default: https://mainnet.sorobanrpc.com) */
20
+ rpcUrl?: string;
21
+ /** Horizon URL (default: https://horizon.stellar.org) */
22
+ horizonUrl?: string;
23
+ /** Request timeout in ms (default: 60000) */
24
+ timeout?: number;
25
+ }
26
+ export interface CreateCardParams {
27
+ amount: 10 | 25 | 50 | 100 | 200 | 500;
28
+ nameOnCard: string;
29
+ email: string;
30
+ }
31
+ export interface FundCardParams {
32
+ amount: 10 | 25 | 50 | 100 | 200 | 500;
33
+ cardId: string;
34
+ }
35
+ export interface TierEntry {
36
+ loadAmount?: number;
37
+ fundAmount?: number;
38
+ totalCost: number;
39
+ endpoint: string;
40
+ breakdown?: Record<string, number>;
41
+ }
42
+ export interface TierResponse {
43
+ creation: TierEntry[];
44
+ funding: TierEntry[];
45
+ }
46
+ export interface BillingAddress {
47
+ street: string;
48
+ city: string;
49
+ state: string;
50
+ zip: string;
51
+ country: string;
52
+ }
53
+ export interface SensitiveCardDetails {
54
+ cardNumber: string;
55
+ expiryMonth: number;
56
+ expiryYear: number;
57
+ cvv: string;
58
+ billingAddress: BillingAddress;
59
+ }
60
+ export interface CardResult {
61
+ success: boolean;
62
+ card: {
63
+ cardId: string;
64
+ nameOnCard: string;
65
+ balance: number;
66
+ status: string;
67
+ createdAt: string;
68
+ };
69
+ payment: {
70
+ amountCharged: number;
71
+ txHash: string;
72
+ network: string;
73
+ };
74
+ /** Sensitive card details (agent-first model, one-time access) */
75
+ detailsEnvelope?: {
76
+ cardNumber: string;
77
+ expiryMonth: number;
78
+ expiryYear: number;
79
+ cvv: string;
80
+ billingAddress: BillingAddress;
81
+ oneTimeAccess: boolean;
82
+ expiresInSeconds: number;
83
+ };
84
+ /** @deprecated use detailsEnvelope */
85
+ details?: SensitiveCardDetails;
86
+ }
87
+ export interface FundResult {
88
+ success: boolean;
89
+ cardId: string;
90
+ fundedAmount: number;
91
+ newBalance: number;
92
+ payment: {
93
+ amountCharged: number;
94
+ txHash: string;
95
+ network: string;
96
+ };
97
+ }
98
+ export interface HealthResponse {
99
+ status: string;
100
+ timestamp: string;
101
+ version: string;
102
+ }
103
+ export interface X402Accept {
104
+ scheme: "exact";
105
+ network: string;
106
+ asset: string;
107
+ amount: string;
108
+ payTo: string;
109
+ maxTimeoutSeconds: number;
110
+ extra?: {
111
+ areFeesSponsored?: boolean;
112
+ [key: string]: unknown;
113
+ };
114
+ }
115
+ export interface X402Challenge {
116
+ x402Version: 2;
117
+ accepts: X402Accept[];
118
+ resource?: {
119
+ url: string;
120
+ description: string;
121
+ mimeType: string;
122
+ };
123
+ }
124
+ export interface X402PaymentPayload {
125
+ x402Version: 2;
126
+ accepted: X402Accept;
127
+ payload: {
128
+ transaction: string;
129
+ };
130
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * @asgcard/sdk — type definitions
4
+ * x402 payment protocol on Stellar (Soroban SAC USDC)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @asgcard/sdk — x402 payment utilities for Stellar
3
+ *
4
+ * Builds and signs Soroban SAC USDC transfer transactions
5
+ * for the x402 payment protocol.
6
+ */
7
+ import { Keypair, rpc as StellarRpc } from "@stellar/stellar-sdk";
8
+ import type { WalletAdapter, X402Accept } from "../types";
9
+ export declare const parseChallenge: (input: unknown) => X402Accept;
10
+ export declare const checkBalance: (params: {
11
+ rpcServer: StellarRpc.Server;
12
+ publicKey: string;
13
+ asset: string;
14
+ requiredAtomic: bigint;
15
+ }) => Promise<void>;
16
+ /**
17
+ * Build a Soroban SAC USDC transfer transaction, simulate, assemble and sign.
18
+ * Returns the signed transaction XDR string ready for the facilitator.
19
+ */
20
+ export declare const buildPaymentTransaction: (params: {
21
+ rpcServer: StellarRpc.Server;
22
+ publicKey: string;
23
+ accept: X402Accept;
24
+ signer: Keypair;
25
+ }) => Promise<string>;
26
+ export declare const executePayment: (params: {
27
+ rpcServer: StellarRpc.Server;
28
+ accept: X402Accept;
29
+ keypair?: Keypair;
30
+ walletAdapter?: WalletAdapter;
31
+ }) => Promise<string>;
32
+ export declare const buildPaymentPayload: (accepted: X402Accept, signedTransactionXDR: string) => string;
33
+ export declare const handleX402Payment: (params: {
34
+ rpcServer: StellarRpc.Server;
35
+ challengePayload: unknown;
36
+ keypair?: Keypair;
37
+ walletAdapter?: WalletAdapter;
38
+ }) => Promise<string>;
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleX402Payment = exports.buildPaymentPayload = exports.executePayment = exports.buildPaymentTransaction = exports.checkBalance = exports.parseChallenge = void 0;
4
+ /**
5
+ * @asgcard/sdk — x402 payment utilities for Stellar
6
+ *
7
+ * Builds and signs Soroban SAC USDC transfer transactions
8
+ * for the x402 payment protocol.
9
+ */
10
+ const stellar_sdk_1 = require("@stellar/stellar-sdk");
11
+ const errors_1 = require("../errors");
12
+ const DEFAULT_FEE = "1000000";
13
+ const SOROBAN_TIMEOUT = 300;
14
+ // ── Challenge parsing ────────────────────────────────────
15
+ const isChallenge = (input) => {
16
+ if (!input || typeof input !== "object")
17
+ return false;
18
+ const r = input;
19
+ return r.x402Version === 2 && Array.isArray(r.accepts);
20
+ };
21
+ const parseChallenge = (input) => {
22
+ if (!isChallenge(input) || input.accepts.length === 0) {
23
+ throw new errors_1.PaymentError("Invalid x402 challenge payload");
24
+ }
25
+ return input.accepts[0];
26
+ };
27
+ exports.parseChallenge = parseChallenge;
28
+ // ── Balance check ────────────────────────────────────────
29
+ const checkBalance = async (params) => {
30
+ const contract = new stellar_sdk_1.Contract(params.asset);
31
+ const account = await params.rpcServer.getAccount(params.publicKey);
32
+ const tx = new stellar_sdk_1.TransactionBuilder(account, {
33
+ fee: DEFAULT_FEE,
34
+ networkPassphrase: stellar_sdk_1.Networks.PUBLIC,
35
+ })
36
+ .addOperation(contract.call("balance", (0, stellar_sdk_1.nativeToScVal)(stellar_sdk_1.Address.fromString(params.publicKey).toScAddress(), { type: "address" })))
37
+ .setTimeout(30)
38
+ .build();
39
+ const sim = await params.rpcServer.simulateTransaction(tx);
40
+ if (!stellar_sdk_1.rpc.Api.isSimulationSuccess(sim)) {
41
+ throw new errors_1.InsufficientBalanceError(params.requiredAtomic.toString(), "0");
42
+ }
43
+ const successSim = sim;
44
+ const retVal = successSim.result?.retval;
45
+ let balance = 0n;
46
+ if (retVal) {
47
+ try {
48
+ balance = BigInt(retVal.value()?.toString() ?? "0");
49
+ }
50
+ catch {
51
+ balance = 0n;
52
+ }
53
+ }
54
+ if (balance < params.requiredAtomic) {
55
+ throw new errors_1.InsufficientBalanceError(params.requiredAtomic.toString(), balance.toString());
56
+ }
57
+ };
58
+ exports.checkBalance = checkBalance;
59
+ // ── Build + sign payment transaction ─────────────────────
60
+ /**
61
+ * Build a Soroban SAC USDC transfer transaction, simulate, assemble and sign.
62
+ * Returns the signed transaction XDR string ready for the facilitator.
63
+ */
64
+ const buildPaymentTransaction = async (params) => {
65
+ const contract = new stellar_sdk_1.Contract(params.accept.asset);
66
+ const sourceAccount = await params.rpcServer.getAccount(params.publicKey);
67
+ const tx = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
68
+ fee: DEFAULT_FEE,
69
+ networkPassphrase: stellar_sdk_1.Networks.PUBLIC,
70
+ })
71
+ .addOperation(contract.call("transfer", (0, stellar_sdk_1.nativeToScVal)(stellar_sdk_1.Address.fromString(params.publicKey).toScAddress(), { type: "address" }), (0, stellar_sdk_1.nativeToScVal)(stellar_sdk_1.Address.fromString(params.accept.payTo).toScAddress(), { type: "address" }), (0, stellar_sdk_1.nativeToScVal)(BigInt(params.accept.amount), { type: "i128" })))
72
+ .setTimeout(SOROBAN_TIMEOUT)
73
+ .build();
74
+ // Simulate to get the auth + resource footprint
75
+ const sim = await params.rpcServer.simulateTransaction(tx);
76
+ if (!stellar_sdk_1.rpc.Api.isSimulationSuccess(sim)) {
77
+ const errMsg = stellar_sdk_1.rpc.Api.isSimulationError(sim)
78
+ ? sim.error
79
+ : "Simulation failed";
80
+ throw new errors_1.PaymentError(`Transaction simulation failed: ${errMsg}`);
81
+ }
82
+ // Assemble the transaction with simulation results (auth entries + footprint)
83
+ const assembled = stellar_sdk_1.rpc.assembleTransaction(tx, sim).build();
84
+ // Sign
85
+ assembled.sign(params.signer);
86
+ return assembled.toXDR();
87
+ };
88
+ exports.buildPaymentTransaction = buildPaymentTransaction;
89
+ // ── Execute payment ──────────────────────────────────────
90
+ const executePayment = async (params) => {
91
+ if (!params.keypair && !params.walletAdapter) {
92
+ throw new errors_1.PaymentError("No signing wallet configured");
93
+ }
94
+ const publicKey = params.keypair
95
+ ? params.keypair.publicKey()
96
+ : params.walletAdapter.publicKey;
97
+ // Optional balance check — non-critical
98
+ try {
99
+ await (0, exports.checkBalance)({
100
+ rpcServer: params.rpcServer,
101
+ publicKey,
102
+ asset: params.accept.asset,
103
+ requiredAtomic: BigInt(params.accept.amount),
104
+ });
105
+ }
106
+ catch (error) {
107
+ if (error instanceof errors_1.InsufficientBalanceError)
108
+ throw error;
109
+ // Swallow non-balance errors — facilitator will verify
110
+ }
111
+ // Build, simulate, assemble, sign
112
+ if (params.keypair) {
113
+ return (0, exports.buildPaymentTransaction)({
114
+ rpcServer: params.rpcServer,
115
+ publicKey,
116
+ accept: params.accept,
117
+ signer: params.keypair,
118
+ });
119
+ }
120
+ // WalletAdapter path
121
+ const adapter = params.walletAdapter;
122
+ const contract = new stellar_sdk_1.Contract(params.accept.asset);
123
+ const sourceAccount = await params.rpcServer.getAccount(publicKey);
124
+ const tx = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
125
+ fee: DEFAULT_FEE,
126
+ networkPassphrase: stellar_sdk_1.Networks.PUBLIC,
127
+ })
128
+ .addOperation(contract.call("transfer", (0, stellar_sdk_1.nativeToScVal)(stellar_sdk_1.Address.fromString(publicKey).toScAddress(), { type: "address" }), (0, stellar_sdk_1.nativeToScVal)(stellar_sdk_1.Address.fromString(params.accept.payTo).toScAddress(), { type: "address" }), (0, stellar_sdk_1.nativeToScVal)(BigInt(params.accept.amount), { type: "i128" })))
129
+ .setTimeout(SOROBAN_TIMEOUT)
130
+ .build();
131
+ const sim = await params.rpcServer.simulateTransaction(tx);
132
+ if (!stellar_sdk_1.rpc.Api.isSimulationSuccess(sim)) {
133
+ throw new errors_1.PaymentError("Transaction simulation failed");
134
+ }
135
+ const assembled = stellar_sdk_1.rpc.assembleTransaction(tx, sim).build();
136
+ return adapter.signTransaction(assembled.toXDR(), stellar_sdk_1.Networks.PUBLIC);
137
+ };
138
+ exports.executePayment = executePayment;
139
+ // ── Build x402 PaymentPayload ────────────────────────────
140
+ const buildPaymentPayload = (accepted, signedTransactionXDR) => {
141
+ const payload = {
142
+ x402Version: 2,
143
+ accepted,
144
+ payload: {
145
+ transaction: signedTransactionXDR,
146
+ },
147
+ };
148
+ return Buffer.from(JSON.stringify(payload), "utf8").toString("base64");
149
+ };
150
+ exports.buildPaymentPayload = buildPaymentPayload;
151
+ // ── Full handleX402Payment ───────────────────────────────
152
+ const handleX402Payment = async (params) => {
153
+ const accept = (0, exports.parseChallenge)(params.challengePayload);
154
+ const signedXDR = await (0, exports.executePayment)({
155
+ rpcServer: params.rpcServer,
156
+ accept,
157
+ keypair: params.keypair,
158
+ walletAdapter: params.walletAdapter,
159
+ });
160
+ return (0, exports.buildPaymentPayload)(accept, signedXDR);
161
+ };
162
+ exports.handleX402Payment = handleX402Payment;
163
+ //# sourceMappingURL=x402.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"x402.js","sourceRoot":"","sources":["../../src/utils/x402.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,sDAQ8B;AAC9B,sCAAmE;AAQnE,MAAM,WAAW,G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,MAAM,OAAO,GAAuB;QAClC,WAAW,EAAE,CAAC;QACd,QAAQ;QACR,OAAO,EAAE;YACP,WAAW,EAAE,oBAAoB;SAClC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzE,CAAC,CAAC;AAbW,QAAA,mBAAmB,uBAa9B;AAEF,4DAA4D;AAErD,MAAM,iBAAiB,GAAG,KAAK,EAAE,MAKvC,EAAmB,EAAE;IACpB,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAEvD,MAAM,SAAS,GAAG,MAAM,IAAA,sBAAc,EAAC;QACrC,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM;QACN,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;IAEH,OAAO,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC,CAAC;AAhBW,QAAA,iBAAiB,qBAgB5B"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@asgcard/sdk",
3
+ "version": "1.0.0",
4
+ "description": "SDK for ASG Card — virtual Visa cards for AI agents, paid via x402 on Stellar",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc -p tsconfig.json",
15
+ "typecheck": "tsc -p tsconfig.json --noEmit",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "keywords": [
19
+ "asgcard",
20
+ "virtual-card",
21
+ "ai-agent",
22
+ "x402",
23
+ "stellar",
24
+ "usdc",
25
+ "soroban"
26
+ ],
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/asgcard/sdk"
31
+ },
32
+ "homepage": "https://asgcard.dev",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "dependencies": {
37
+ "@stellar/stellar-sdk": "^13.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^22.15.30",
41
+ "typescript": "^5.8.3"
42
+ }
43
+ }