@attesso/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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Attesso
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ # @attesso/sdk
2
+
3
+ The official TypeScript SDK for Attesso. Hardware-backed identity for autonomous commerce.
4
+
5
+ ```bash
6
+ npm install @attesso/sdk
7
+ ```
8
+
9
+ ## What This Is
10
+
11
+ AI agents need to spend money. Attesso gives them a wallet with hardware-backed security and user-controlled spending limits.
12
+
13
+ This SDK lets agents:
14
+ - Execute payments within pre-authorized limits
15
+ - Prove their identity to merchants
16
+ - Check available spending power
17
+
18
+ **No mobile app required.** Users authorize spending with WebAuthn passkeys (FaceID/TouchID) directly in the browser.
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { AttessoClient } from '@attesso/sdk';
24
+
25
+ const client = new AttessoClient({
26
+ apiKey: process.env.ATTESSO_API_KEY,
27
+ });
28
+
29
+ // Check mandate limits
30
+ const mandate = await client.getMandate('mandate_xyz');
31
+ console.log(`Available: $${mandate.maxAmount / 100}`);
32
+
33
+ // Execute payment
34
+ const payment = await client.executePayment({
35
+ mandateId: 'mandate_xyz',
36
+ amount: 34700, // $347.00
37
+ merchant: 'United Airlines',
38
+ });
39
+
40
+ // Get identity token for merchant verification
41
+ const passport = await client.getPassport('mandate_xyz');
42
+ ```
43
+
44
+ ## How Users Create Mandates
45
+
46
+ Users create spending mandates in your web dashboard using WebAuthn passkeys:
47
+
48
+ ```typescript
49
+ // Frontend: User creates mandate with passkey
50
+ import { startAuthentication } from '@simplewebauthn/browser';
51
+
52
+ // 1. Get authentication options from your backend
53
+ const authOptions = await fetch('/api/auth/webauthn/authenticate/options', {
54
+ method: 'POST',
55
+ }).then(r => r.json());
56
+
57
+ // 2. User authenticates with FaceID/TouchID (or QR code on desktop)
58
+ const assertion = await startAuthentication(authOptions);
59
+
60
+ // 3. Create mandate with the assertion
61
+ const mandate = await fetch('/api/mandates', {
62
+ method: 'POST',
63
+ headers: { 'Content-Type': 'application/json' },
64
+ body: JSON.stringify({
65
+ botId: 'bot_travel_agent',
66
+ maxAmount: 50000, // $500.00
67
+ currency: 'usd',
68
+ merchant: 'United Airlines',
69
+ webAuthnAssertion: assertion,
70
+ }),
71
+ }).then(r => r.json());
72
+
73
+ // 4. Pass mandateId to your AI agent
74
+ ```
75
+
76
+ ### Cross-Device Authentication
77
+
78
+ On desktops without biometrics (TouchID), WebAuthn automatically shows a QR code. Users scan it with their phone and authenticate using the phone's FaceID/TouchID. The signature still comes from hardware (phone's Secure Enclave).
79
+
80
+ ## Vercel AI SDK Integration
81
+
82
+ One line gives your AI agent a wallet:
83
+
84
+ ```typescript
85
+ import { generateText } from 'ai';
86
+ import { attesso } from '@attesso/sdk/vercel';
87
+
88
+ const result = await generateText({
89
+ model: openai('gpt-4o'),
90
+ tools: attesso.tools(),
91
+ prompt: 'Book me a flight to NYC under $500',
92
+ });
93
+ ```
94
+
95
+ ### Available Tools
96
+
97
+ | Tool | Description |
98
+ |------|-------------|
99
+ | `attesso_pay` | Execute payment against mandate |
100
+ | `attesso_get_mandate` | Check spending limits |
101
+ | `attesso_get_passport` | Get identity token |
102
+ | `attesso_capture` | Capture authorized payment |
103
+ | `attesso_cancel` | Cancel and release funds |
104
+ | `attesso_check_balance` | Quick balance check |
105
+
106
+ ### Configuration
107
+
108
+ ```typescript
109
+ const tools = attesso.tools({
110
+ mandateId: 'mandate_xyz', // Pre-select mandate
111
+ merchant: 'United Airlines', // Lock to merchant
112
+ maxAmountPerTransaction: 50000, // $500 cap
113
+ });
114
+ ```
115
+
116
+ ## Direct API Access
117
+
118
+ ```typescript
119
+ import { AttessoClient } from '@attesso/sdk';
120
+
121
+ const client = new AttessoClient({ apiKey: '...' });
122
+
123
+ // Get mandate details
124
+ const mandate = await client.getMandate(mandateId);
125
+
126
+ // Execute payment
127
+ const payment = await client.executePayment({
128
+ mandateId,
129
+ amount: 10000,
130
+ merchant: 'Acme Corp',
131
+ });
132
+
133
+ // Check payment status
134
+ const status = await client.getPayment(payment.id);
135
+
136
+ // Auth/Capture flow
137
+ const auth = await client.executePayment({
138
+ mandateId,
139
+ amount: 50000,
140
+ merchant: 'Hotel',
141
+ });
142
+ await client.capture(auth.id, { amount: 45000 }); // Final price
143
+
144
+ // Cancel authorization
145
+ await client.cancel(auth.id);
146
+
147
+ // Get passport token
148
+ const passport = await client.getPassport(mandateId);
149
+ ```
150
+
151
+ ## How It Works
152
+
153
+ ```
154
+ User creates mandate → WebAuthn passkey signs authorization
155
+ ↓ (FaceID/TouchID or phone QR)
156
+ Mandate stored → Hardware attestation verified
157
+
158
+ AI Agent calls SDK → SDK checks mandate limits
159
+
160
+ Payment executed → Funds transferred via Stripe
161
+
162
+ Merchant verifies → Passport proves authorized spending
163
+ ```
164
+
165
+ ### Security Model
166
+
167
+ - **WebAuthn Passkeys**: Mandates signed by device Secure Enclave
168
+ - **Cross-Device Support**: QR-based authentication for desktops
169
+ - **User Control**: Instant revocation, spending limits
170
+ - **Cryptographic Identity**: JWT passports verifiable offline
171
+
172
+ ## Infrastructure Security
173
+
174
+ ### Idempotency
175
+ - Idempotency keys required on all payment operations
176
+ - Concurrent duplicates return `409 Conflict`
177
+ - Request payloads hashed to detect tampering
178
+
179
+ ### WebAuthn
180
+ - Origin-bound credentials (phishing-resistant)
181
+ - Single-use challenges with TTL
182
+ - Hardware counter validation
183
+
184
+ ### Rate Limiting
185
+ | Endpoint | Limit |
186
+ |----------|-------|
187
+ | Auth | 5/min |
188
+ | Payments | 30/min |
189
+ | General | 100/min |
190
+
191
+ ### Webhook Processing
192
+ - Stripe event deduplication via `WebhookEvent` table
193
+ - Row-level locking (`SELECT ... FOR UPDATE`)
194
+ - Serializable transaction isolation
195
+
196
+ ### Hardware Security by Device
197
+
198
+ | Device | Security | Auth Method |
199
+ |--------|----------|-------------|
200
+ | iPhone/iPad | Secure Enclave | FaceID/TouchID |
201
+ | Mac (Touch ID) | Secure Enclave | TouchID |
202
+ | Mac (no Touch ID) | Phone via QR | Phone's Secure Enclave |
203
+ | Windows (Hello) | TPM 2.0 | Windows Hello |
204
+ | Windows (no Hello) | Phone via QR | Requires Bluetooth + manual selection |
205
+ | Android | TEE/StrongBox | Fingerprint/Face |
206
+
207
+ **Windows Note:** Without Windows Hello, users see a USB security key prompt first. They must click Cancel and select "iPhone/Android" for QR code. Bluetooth must be enabled.
208
+
209
+ ## Application Fee Routing (Optional)
210
+
211
+ Configure application fees per transaction. The protocol uses an additive settlement model, calculating charges on top of the base amount. This ensures merchant principal preservation while automating fee routing to the connected Stripe account.
212
+
213
+ ### Configuration
214
+
215
+ ```typescript
216
+ // Principal is $100, total authorization is $106
217
+ const payment = await rails.processPayment({
218
+ amount: 10000, // $100.00 principal amount
219
+ currency: 'usd',
220
+ merchant: 'Acme Corp',
221
+ mandateId: 'mandate_xyz',
222
+ paymentId: 'payment_abc',
223
+ userId: 'user_123',
224
+ applicationFee: {
225
+ destinationAccountId: 'acct_your_stripe_connect_id',
226
+ feePercent: 5, // percentage of principal
227
+ // OR
228
+ feeFixed: 100, // fixed amount (cents)
229
+ // OR both combined
230
+ },
231
+ });
232
+ ```
233
+
234
+ ### Fee Routing Options
235
+
236
+ | Parameter | Example | On $100 principal |
237
+ |-----------|---------|-------------------|
238
+ | `feePercent` | `5` | +$5.00 |
239
+ | `feeFixed` | `100` | +$1.00 |
240
+ | Hybrid | `{ percent: 2, fixed: 30 }` | +$2.30 |
241
+
242
+ ### Settlement Model
243
+
244
+ $100 principal with 1% protocol fee + 5% application fee:
245
+
246
+ | Settlement | Amount |
247
+ |------------|--------|
248
+ | Net Settlement (Merchant) | $100.00 |
249
+ | Protocol Fee (Attesso) | $1.00 |
250
+ | Application Fee | $5.00 |
251
+ | **Total Authorization** | **$106.00** |
252
+
253
+ ```typescript
254
+ const settlement = rails.calculateFees(10000, 5, 0);
255
+ // { netSettlement: 10000, protocolFee: 100, applicationFee: 500, totalAuthorization: 10600 }
256
+ ```
257
+
258
+ ### Requirements
259
+
260
+ - Stripe Connect account (`acct_...` ID)
261
+ - Application fee routing is optional—omit to disable
262
+
263
+ ## Origin Restrictions (Optional)
264
+
265
+ Restrict SDK usage to specific domains:
266
+
267
+ ```typescript
268
+ const client = new AttessoClient({
269
+ apiKey: 'sk_bot_xyz',
270
+ allowedOrigins: [
271
+ 'https://myapp.com',
272
+ 'https://*.trusted-partner.com', // Wildcard subdomains
273
+ ],
274
+ });
275
+ ```
276
+
277
+ Requests from non-allowed origins throw `OriginNotAllowedError`.
278
+
279
+ ## Environment Variables
280
+
281
+ ```bash
282
+ ATTESSO_API_KEY=your_api_key
283
+ ATTESSO_BASE_URL=https://api.attesso.dev # optional
284
+ ```
285
+
286
+ ## TypeScript
287
+
288
+ Full type safety included:
289
+
290
+ ```typescript
291
+ import type {
292
+ MandateResponse,
293
+ PaymentResponse,
294
+ PassportToken,
295
+ WebAuthnAssertion,
296
+ } from '@attesso/sdk';
297
+ ```
298
+
299
+ ## Requirements
300
+
301
+ - Node.js 18+
302
+ - For Vercel AI SDK integration: `ai` >= 3.0, `zod` >= 3.0
303
+
304
+ ## License
305
+
306
+ MIT
@@ -0,0 +1,129 @@
1
+ import type { MandateResponse, PaymentResponse, PassportToken, CapturePaymentResponse, CancelAuthorizationResponse } from '@attesso/types';
2
+ export interface AttessoClientConfig {
3
+ apiKey?: string;
4
+ apiUrl?: string;
5
+ baseUrl?: string;
6
+ /**
7
+ * List of allowed origins/domains where the SDK can operate.
8
+ * If set, SDK will only allow operations when running on these domains.
9
+ * Supports exact matches and wildcard subdomains (e.g., "*.example.com").
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const client = new AttessoClient({
14
+ * apiKey: 'sk_bot_xyz',
15
+ * allowedOrigins: ['https://shop.example.com', 'https://*.trusted-merchant.com']
16
+ * });
17
+ * ```
18
+ */
19
+ allowedOrigins?: string[];
20
+ }
21
+ export interface ExecutePaymentOptions {
22
+ mandateId: string;
23
+ amount: number;
24
+ merchant: string;
25
+ }
26
+ export interface CapturePaymentOptions {
27
+ amount: number;
28
+ metadata?: Record<string, string>;
29
+ }
30
+ export declare class AttessoClient {
31
+ private apiKey;
32
+ private baseUrl;
33
+ private allowedOrigins;
34
+ constructor(config?: AttessoClientConfig);
35
+ /**
36
+ * Check if the current origin is allowed.
37
+ * Returns true if no restrictions are set or if the current origin matches.
38
+ */
39
+ private isOriginAllowed;
40
+ /**
41
+ * Match origin against allowed pattern.
42
+ * Supports wildcards for subdomains (e.g., "*.example.com").
43
+ */
44
+ private matchesOrigin;
45
+ /**
46
+ * Get the current origin (browser context).
47
+ */
48
+ private getCurrentOrigin;
49
+ /**
50
+ * Validate that the current origin is allowed before making requests.
51
+ * Throws OriginNotAllowedError if origin is restricted.
52
+ */
53
+ private validateOrigin;
54
+ private request;
55
+ /**
56
+ * Get a mandate by ID.
57
+ */
58
+ getMandate(mandateId: string): Promise<MandateResponse>;
59
+ /**
60
+ * Execute a payment against a mandate.
61
+ * This is the main method bots use to make purchases.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const aegis = new AttessoClient({ apiKey: 'your-api-key' });
66
+ *
67
+ * const payment = await aegis.executePayment({
68
+ * mandateId: 'mandate_xyz',
69
+ * amount: 75000, // $750.00 in cents
70
+ * merchant: 'United Airlines'
71
+ * });
72
+ *
73
+ * console.log(`Payment ${payment.id} status: ${payment.status}`);
74
+ * ```
75
+ */
76
+ executePayment(options: ExecutePaymentOptions): Promise<PaymentResponse>;
77
+ /**
78
+ * Get a payment by ID.
79
+ */
80
+ getPayment(paymentId: string): Promise<PaymentResponse>;
81
+ /**
82
+ * Get a passport token for making authenticated requests to merchants.
83
+ * The passport proves to the merchant that this request has authorized spending.
84
+ */
85
+ getPassport(mandateId: string): Promise<PassportToken>;
86
+ /**
87
+ * Capture a previously authorized payment.
88
+ * The capture amount must be less than or equal to the authorized amount.
89
+ *
90
+ * @param paymentId - The ID of the authorized payment
91
+ * @param options - Capture options including the final amount
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const payment = await attesso.capture('payment_abc123', {
96
+ * amount: 34700, // $347.00 actual price
97
+ * });
98
+ * ```
99
+ */
100
+ capture(paymentId: string, options: CapturePaymentOptions): Promise<CapturePaymentResponse>;
101
+ /**
102
+ * Cancel an authorization and release the hold on funds.
103
+ * Use this when the purchase won't proceed (e.g., user cancelled, no suitable flights found).
104
+ *
105
+ * @param paymentId - The ID of the authorized payment to cancel
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * // User decided not to book
110
+ * const result = await attesso.cancel('payment_abc123');
111
+ * console.log('Funds released');
112
+ * ```
113
+ */
114
+ cancel(paymentId: string): Promise<CancelAuthorizationResponse>;
115
+ }
116
+ export declare class AttessoError extends Error {
117
+ code: string;
118
+ constructor(code: string, message: string);
119
+ }
120
+ /**
121
+ * Error thrown when SDK is used from a disallowed origin.
122
+ */
123
+ export declare class OriginNotAllowedError extends Error {
124
+ code: string;
125
+ currentOrigin: string;
126
+ allowedOrigins: string[];
127
+ constructor(currentOrigin: string, allowedOrigins: string[]);
128
+ }
129
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAEf,eAAe,EAEf,aAAa,EACb,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;OAYG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAuB;gBAEjC,MAAM,GAAE,mBAAwB;IAM5C;;;OAGG;IACH,OAAO,CAAC,eAAe;IAmBvB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAoCrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;OAGG;IACH,OAAO,CAAC,cAAc;YAUR,OAAO;IA8BrB;;OAEG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI7D;;;;;;;;;;;;;;;;OAgBG;IACG,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC;IAU9E;;OAEG;IACG,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI7D;;;OAGG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAc5D;;;;;;;;;;;;;OAaG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAQjG;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAMtE;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,IAAI,EAAE,MAAM,CAAwB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;gBAEb,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE;CAS5D"}
package/dist/client.js ADDED
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OriginNotAllowedError = exports.AttessoError = exports.AttessoClient = void 0;
4
+ class AttessoClient {
5
+ apiKey;
6
+ baseUrl;
7
+ allowedOrigins;
8
+ constructor(config = {}) {
9
+ this.apiKey = config.apiKey;
10
+ this.baseUrl = config.apiUrl ?? config.baseUrl ?? 'https://api.attesso.dev';
11
+ this.allowedOrigins = config.allowedOrigins;
12
+ }
13
+ /**
14
+ * Check if the current origin is allowed.
15
+ * Returns true if no restrictions are set or if the current origin matches.
16
+ */
17
+ isOriginAllowed(origin) {
18
+ if (!this.allowedOrigins || this.allowedOrigins.length === 0) {
19
+ return true;
20
+ }
21
+ // In Node.js/server context, origin may not exist - allow by default
22
+ if (!origin) {
23
+ return true;
24
+ }
25
+ for (const allowed of this.allowedOrigins) {
26
+ if (this.matchesOrigin(origin, allowed)) {
27
+ return true;
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+ /**
33
+ * Match origin against allowed pattern.
34
+ * Supports wildcards for subdomains (e.g., "*.example.com").
35
+ */
36
+ matchesOrigin(origin, pattern) {
37
+ // Exact match
38
+ if (origin === pattern) {
39
+ return true;
40
+ }
41
+ // Parse both URLs
42
+ try {
43
+ const originUrl = new URL(origin);
44
+ const patternUrl = new URL(pattern);
45
+ // Protocol must match
46
+ if (originUrl.protocol !== patternUrl.protocol) {
47
+ return false;
48
+ }
49
+ // Handle wildcard subdomain matching
50
+ const patternHost = patternUrl.hostname;
51
+ const originHost = originUrl.hostname;
52
+ if (patternHost.startsWith('*.')) {
53
+ const baseDomain = patternHost.slice(2); // Remove "*."
54
+ // Origin must end with the base domain
55
+ if (originHost === baseDomain || originHost.endsWith('.' + baseDomain)) {
56
+ return true;
57
+ }
58
+ }
59
+ // Exact hostname match
60
+ return originHost === patternHost;
61
+ }
62
+ catch {
63
+ // If URL parsing fails, do simple string match
64
+ return origin === pattern;
65
+ }
66
+ }
67
+ /**
68
+ * Get the current origin (browser context).
69
+ */
70
+ getCurrentOrigin() {
71
+ if (typeof window !== 'undefined' && window.location) {
72
+ return window.location.origin;
73
+ }
74
+ return undefined;
75
+ }
76
+ /**
77
+ * Validate that the current origin is allowed before making requests.
78
+ * Throws OriginNotAllowedError if origin is restricted.
79
+ */
80
+ validateOrigin() {
81
+ const currentOrigin = this.getCurrentOrigin();
82
+ if (!this.isOriginAllowed(currentOrigin)) {
83
+ throw new OriginNotAllowedError(currentOrigin || 'unknown', this.allowedOrigins || []);
84
+ }
85
+ }
86
+ async request(method, path, body) {
87
+ // Validate origin before making any request
88
+ this.validateOrigin();
89
+ const headers = {
90
+ 'Content-Type': 'application/json',
91
+ };
92
+ if (this.apiKey) {
93
+ headers['Authorization'] = `Bearer ${this.apiKey}`;
94
+ }
95
+ const response = await fetch(`${this.baseUrl}${path}`, {
96
+ method,
97
+ headers,
98
+ body: body ? JSON.stringify(body) : undefined,
99
+ });
100
+ if (!response.ok) {
101
+ const error = (await response.json());
102
+ throw new AttessoError(error.code, error.message);
103
+ }
104
+ return response.json();
105
+ }
106
+ /**
107
+ * Get a mandate by ID.
108
+ */
109
+ async getMandate(mandateId) {
110
+ return this.request('GET', `/v1/mandates/${mandateId}`);
111
+ }
112
+ /**
113
+ * Execute a payment against a mandate.
114
+ * This is the main method bots use to make purchases.
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const aegis = new AttessoClient({ apiKey: 'your-api-key' });
119
+ *
120
+ * const payment = await aegis.executePayment({
121
+ * mandateId: 'mandate_xyz',
122
+ * amount: 75000, // $750.00 in cents
123
+ * merchant: 'United Airlines'
124
+ * });
125
+ *
126
+ * console.log(`Payment ${payment.id} status: ${payment.status}`);
127
+ * ```
128
+ */
129
+ async executePayment(options) {
130
+ const request = {
131
+ mandateId: options.mandateId,
132
+ amount: options.amount,
133
+ merchant: options.merchant,
134
+ };
135
+ return this.request('POST', '/v1/payments', request);
136
+ }
137
+ /**
138
+ * Get a payment by ID.
139
+ */
140
+ async getPayment(paymentId) {
141
+ return this.request('GET', `/v1/payments/${paymentId}`);
142
+ }
143
+ /**
144
+ * Get a passport token for making authenticated requests to merchants.
145
+ * The passport proves to the merchant that this request has authorized spending.
146
+ */
147
+ async getPassport(mandateId) {
148
+ return this.request('POST', `/v1/passports/mandate/${mandateId}`);
149
+ }
150
+ // ============================================================
151
+ // CAPTURE & CANCEL METHODS
152
+ // Note: Authorization happens automatically when the USER creates
153
+ // a mandate via FaceID on their mobile app. Bots can only capture
154
+ // or cancel existing authorizations.
155
+ // ============================================================
156
+ /**
157
+ * Capture a previously authorized payment.
158
+ * The capture amount must be less than or equal to the authorized amount.
159
+ *
160
+ * @param paymentId - The ID of the authorized payment
161
+ * @param options - Capture options including the final amount
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const payment = await attesso.capture('payment_abc123', {
166
+ * amount: 34700, // $347.00 actual price
167
+ * });
168
+ * ```
169
+ */
170
+ async capture(paymentId, options) {
171
+ return this.request('POST', `/v1/payments/${paymentId}/capture`, options);
172
+ }
173
+ /**
174
+ * Cancel an authorization and release the hold on funds.
175
+ * Use this when the purchase won't proceed (e.g., user cancelled, no suitable flights found).
176
+ *
177
+ * @param paymentId - The ID of the authorized payment to cancel
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * // User decided not to book
182
+ * const result = await attesso.cancel('payment_abc123');
183
+ * console.log('Funds released');
184
+ * ```
185
+ */
186
+ async cancel(paymentId) {
187
+ return this.request('POST', `/v1/payments/${paymentId}/cancel`);
188
+ }
189
+ }
190
+ exports.AttessoClient = AttessoClient;
191
+ class AttessoError extends Error {
192
+ code;
193
+ constructor(code, message) {
194
+ super(message);
195
+ this.name = 'AttessoError';
196
+ this.code = code;
197
+ }
198
+ }
199
+ exports.AttessoError = AttessoError;
200
+ /**
201
+ * Error thrown when SDK is used from a disallowed origin.
202
+ */
203
+ class OriginNotAllowedError extends Error {
204
+ code = 'ORIGIN_NOT_ALLOWED';
205
+ currentOrigin;
206
+ allowedOrigins;
207
+ constructor(currentOrigin, allowedOrigins) {
208
+ super(`SDK operations are not allowed from origin "${currentOrigin}". ` +
209
+ `Allowed origins: ${allowedOrigins.join(', ')}`);
210
+ this.name = 'OriginNotAllowedError';
211
+ this.currentOrigin = currentOrigin;
212
+ this.allowedOrigins = allowedOrigins;
213
+ }
214
+ }
215
+ exports.OriginNotAllowedError = OriginNotAllowedError;
216
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAyCA,MAAa,aAAa;IAChB,MAAM,CAAqB;IAC3B,OAAO,CAAS;IAChB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,CAAC;IACJ,CAAC;IAED,+DAA+D;IAC/D,2BAA2B;IAC3B,kEAAkE;IAClE,kEAAkE;IAClE,qCAAqC;IACrC,+DAA+D;IAE/D;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,OAAO,CAAC,SAAiB,EAAE,OAA8B;QAC7D,OAAO,IAAI,CAAC,OAAO,CACjB,MAAM,EACN,gBAAgB,SAAS,UAAU,EACnC,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,OAAO,IAAI,CAAC,OAAO,CACjB,MAAM,EACN,gBAAgB,SAAS,SAAS,CACnC,CAAC;IACJ,CAAC;CACF;AApOD,sCAoOC;AAED,MAAa,YAAa,SAAQ,KAAK;IACrC,IAAI,CAAS;IAEb,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,oCAQC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IAC9C,IAAI,GAAW,oBAAoB,CAAC;IACpC,aAAa,CAAS;IACtB,cAAc,CAAW;IAEzB,YAAY,aAAqB,EAAE,cAAwB;QACzD,KAAK,CACH,+CAA+C,aAAa,KAAK;YACjE,oBAAoB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAChD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AAdD,sDAcC"}
@@ -0,0 +1,6 @@
1
+ export { AttessoClient, AttessoError, OriginNotAllowedError } from './client.js';
2
+ export type { AttessoClientConfig, ExecutePaymentOptions, CapturePaymentOptions, } from './client.js';
3
+ export { verifyPassport, clearJwksCache, gatekeeperMiddleware } from '@attesso/gatekeeper';
4
+ export type { VerifyPassportOptions, GatekeeperConfig, AttessoRequest } from '@attesso/gatekeeper';
5
+ export type { Mandate, MandateResponse, MandateStatus, Payment, PaymentResponse, PaymentStatus, PaymentError, PaymentErrorCode, PassportToken, PassportPayload, VerifyPassportResult, CapturePaymentResponse, CancelAuthorizationResponse, } from '@attesso/types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGnG,YAAY,EACV,OAAO,EACP,eAAe,EACf,aAAa,EACb,OAAO,EACP,eAAe,EACf,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.gatekeeperMiddleware = exports.clearJwksCache = exports.verifyPassport = exports.OriginNotAllowedError = exports.AttessoError = exports.AttessoClient = void 0;
4
+ var client_js_1 = require("./client.js");
5
+ Object.defineProperty(exports, "AttessoClient", { enumerable: true, get: function () { return client_js_1.AttessoClient; } });
6
+ Object.defineProperty(exports, "AttessoError", { enumerable: true, get: function () { return client_js_1.AttessoError; } });
7
+ Object.defineProperty(exports, "OriginNotAllowedError", { enumerable: true, get: function () { return client_js_1.OriginNotAllowedError; } });
8
+ // Re-export gatekeeper for one-click merchant DX
9
+ var gatekeeper_1 = require("@attesso/gatekeeper");
10
+ Object.defineProperty(exports, "verifyPassport", { enumerable: true, get: function () { return gatekeeper_1.verifyPassport; } });
11
+ Object.defineProperty(exports, "clearJwksCache", { enumerable: true, get: function () { return gatekeeper_1.clearJwksCache; } });
12
+ Object.defineProperty(exports, "gatekeeperMiddleware", { enumerable: true, get: function () { return gatekeeper_1.gatekeeperMiddleware; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiF;AAAxE,0GAAA,aAAa,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AAO3D,iDAAiD;AACjD,kDAA2F;AAAlF,4GAAA,cAAc,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,kHAAA,oBAAoB,OAAA"}
@@ -0,0 +1,281 @@
1
+ /**
2
+ * Vercel AI SDK Integration for Attesso
3
+ *
4
+ * Provides pre-built tools that instantly give AI agents wallet and identity capabilities.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { generateText } from 'ai';
9
+ * import { attesso } from '@attesso/sdk/vercel';
10
+ *
11
+ * const result = await generateText({
12
+ * model: openai('gpt-4o'),
13
+ * tools: attesso.tools(),
14
+ * prompt: 'Book me a flight to NYC under $500',
15
+ * });
16
+ * ```
17
+ */
18
+ import { z } from 'zod';
19
+ import { AttessoClient } from '../client.js';
20
+ import type { MandateResponse, PaymentResponse, PassportToken, CapturePaymentResponse, CancelAuthorizationResponse } from '@attesso/types';
21
+ export interface AttessoToolsConfig {
22
+ /**
23
+ * Attesso API key. Falls back to ATTESSO_API_KEY env var.
24
+ */
25
+ apiKey?: string;
26
+ /**
27
+ * Base URL for the Attesso API.
28
+ * @default "https://api.attesso.dev"
29
+ */
30
+ baseUrl?: string;
31
+ /**
32
+ * If provided, the mandate ID to use for all operations.
33
+ * This enables "zero-config" mode where the agent already has a mandate.
34
+ */
35
+ mandateId?: string;
36
+ /**
37
+ * If provided, restrict payments to this merchant only.
38
+ */
39
+ merchant?: string;
40
+ /**
41
+ * Maximum amount (in cents) the agent can spend per transaction.
42
+ * Provides an additional guardrail on top of mandate limits.
43
+ */
44
+ maxAmountPerTransaction?: number;
45
+ }
46
+ /**
47
+ * Zod schemas for tool inputs - these are shared with AI models
48
+ */
49
+ declare const schemas: {
50
+ getMandate: z.ZodObject<{
51
+ mandateId: z.ZodString;
52
+ }, "strip", z.ZodTypeAny, {
53
+ mandateId: string;
54
+ }, {
55
+ mandateId: string;
56
+ }>;
57
+ executePayment: z.ZodObject<{
58
+ mandateId: z.ZodString;
59
+ amount: z.ZodNumber;
60
+ merchant: z.ZodString;
61
+ }, "strip", z.ZodTypeAny, {
62
+ mandateId: string;
63
+ amount: number;
64
+ merchant: string;
65
+ }, {
66
+ mandateId: string;
67
+ amount: number;
68
+ merchant: string;
69
+ }>;
70
+ getPayment: z.ZodObject<{
71
+ paymentId: z.ZodString;
72
+ }, "strip", z.ZodTypeAny, {
73
+ paymentId: string;
74
+ }, {
75
+ paymentId: string;
76
+ }>;
77
+ getPassport: z.ZodObject<{
78
+ mandateId: z.ZodString;
79
+ }, "strip", z.ZodTypeAny, {
80
+ mandateId: string;
81
+ }, {
82
+ mandateId: string;
83
+ }>;
84
+ capture: z.ZodObject<{
85
+ paymentId: z.ZodString;
86
+ amount: z.ZodNumber;
87
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
88
+ }, "strip", z.ZodTypeAny, {
89
+ amount: number;
90
+ paymentId: string;
91
+ metadata?: Record<string, string> | undefined;
92
+ }, {
93
+ amount: number;
94
+ paymentId: string;
95
+ metadata?: Record<string, string> | undefined;
96
+ }>;
97
+ cancel: z.ZodObject<{
98
+ paymentId: z.ZodString;
99
+ }, "strip", z.ZodTypeAny, {
100
+ paymentId: string;
101
+ }, {
102
+ paymentId: string;
103
+ }>;
104
+ checkBalance: z.ZodObject<{
105
+ mandateId: z.ZodString;
106
+ }, "strip", z.ZodTypeAny, {
107
+ mandateId: string;
108
+ }, {
109
+ mandateId: string;
110
+ }>;
111
+ empty: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
112
+ };
113
+ /**
114
+ * Creates the Attesso tools bundle for Vercel AI SDK.
115
+ *
116
+ * @example Basic usage
117
+ * ```typescript
118
+ * import { generateText } from 'ai';
119
+ * import { attesso } from '@attesso/sdk/vercel';
120
+ *
121
+ * const result = await generateText({
122
+ * model: openai('gpt-4o'),
123
+ * tools: attesso.tools(),
124
+ * prompt: 'Book me a flight to NYC',
125
+ * });
126
+ * ```
127
+ *
128
+ * @example With pre-configured mandate
129
+ * ```typescript
130
+ * const result = await generateText({
131
+ * model: openai('gpt-4o'),
132
+ * tools: attesso.tools({
133
+ * mandateId: 'mandate_xyz',
134
+ * maxAmountPerTransaction: 50000, // $500 cap
135
+ * }),
136
+ * prompt: 'Find and book the best hotel deal',
137
+ * });
138
+ * ```
139
+ */
140
+ declare function createAttessoTools(config?: AttessoToolsConfig): {
141
+ /**
142
+ * Get mandate details to check spending limits and status.
143
+ * Use this before making a purchase to verify available funds.
144
+ */
145
+ attesso_get_mandate: import("ai").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, MandateResponse> & {
146
+ execute: (args: {}, options: import("ai").ToolExecutionOptions) => PromiseLike<MandateResponse>;
147
+ };
148
+ /**
149
+ * Execute a payment against a mandate.
150
+ * This is the main tool for making purchases.
151
+ */
152
+ attesso_pay: import("ai").Tool<z.ZodObject<{
153
+ amount: z.ZodNumber;
154
+ }, "strip", z.ZodTypeAny, {
155
+ amount: number;
156
+ }, {
157
+ amount: number;
158
+ }>, PaymentResponse> & {
159
+ execute: (args: {
160
+ amount: number;
161
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<PaymentResponse>;
162
+ };
163
+ /**
164
+ * Get payment status and details.
165
+ */
166
+ attesso_get_payment: import("ai").Tool<z.ZodObject<{
167
+ paymentId: z.ZodString;
168
+ }, "strip", z.ZodTypeAny, {
169
+ paymentId: string;
170
+ }, {
171
+ paymentId: string;
172
+ }>, PaymentResponse> & {
173
+ execute: (args: {
174
+ paymentId: string;
175
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<PaymentResponse>;
176
+ };
177
+ /**
178
+ * Get a passport token for authenticated merchant access.
179
+ * This proves to merchants that the agent has authorized spending power.
180
+ */
181
+ attesso_get_passport: import("ai").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, PassportToken> & {
182
+ execute: (args: {}, options: import("ai").ToolExecutionOptions) => PromiseLike<PassportToken>;
183
+ };
184
+ /**
185
+ * Capture a previously authorized payment.
186
+ * Use this in auth/capture flow when the final price is known.
187
+ */
188
+ attesso_capture: import("ai").Tool<z.ZodObject<{
189
+ paymentId: z.ZodString;
190
+ amount: z.ZodNumber;
191
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
192
+ }, "strip", z.ZodTypeAny, {
193
+ amount: number;
194
+ paymentId: string;
195
+ metadata?: Record<string, string> | undefined;
196
+ }, {
197
+ amount: number;
198
+ paymentId: string;
199
+ metadata?: Record<string, string> | undefined;
200
+ }>, CapturePaymentResponse> & {
201
+ execute: (args: {
202
+ amount: number;
203
+ paymentId: string;
204
+ metadata?: Record<string, string> | undefined;
205
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<CapturePaymentResponse>;
206
+ };
207
+ /**
208
+ * Cancel an authorization and release held funds.
209
+ * Use this when a purchase won't proceed.
210
+ */
211
+ attesso_cancel: import("ai").Tool<z.ZodObject<{
212
+ paymentId: z.ZodString;
213
+ }, "strip", z.ZodTypeAny, {
214
+ paymentId: string;
215
+ }, {
216
+ paymentId: string;
217
+ }>, CancelAuthorizationResponse> & {
218
+ execute: (args: {
219
+ paymentId: string;
220
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<CancelAuthorizationResponse>;
221
+ };
222
+ /**
223
+ * Check remaining balance on a mandate.
224
+ * Convenience tool that wraps getMandate for quick balance checks.
225
+ */
226
+ attesso_check_balance: import("ai").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
227
+ available: number;
228
+ currency: string;
229
+ status: string;
230
+ }> & {
231
+ execute: (args: {}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
232
+ available: number;
233
+ currency: string;
234
+ status: string;
235
+ }>;
236
+ };
237
+ };
238
+ /**
239
+ * Attesso integration for Vercel AI SDK.
240
+ *
241
+ * @example One-import usage
242
+ * ```typescript
243
+ * import { generateText } from 'ai';
244
+ * import { attesso } from '@attesso/sdk/vercel';
245
+ *
246
+ * const result = await generateText({
247
+ * model: openai('gpt-4o'),
248
+ * tools: attesso.tools(),
249
+ * prompt: 'Book me a flight to NYC under $500',
250
+ * });
251
+ * ```
252
+ *
253
+ * @example With configuration
254
+ * ```typescript
255
+ * const result = await generateText({
256
+ * model: openai('gpt-4o'),
257
+ * tools: attesso.tools({
258
+ * mandateId: mandate.id,
259
+ * merchant: 'United Airlines',
260
+ * }),
261
+ * prompt: 'Find and book the cheapest flight',
262
+ * });
263
+ * ```
264
+ */
265
+ export declare const attesso: {
266
+ /**
267
+ * Create Attesso tools for use with Vercel AI SDK.
268
+ * Returns a tool bundle that can be spread into the tools object.
269
+ */
270
+ tools: typeof createAttessoTools;
271
+ /**
272
+ * Create an Attesso client for direct API access.
273
+ * Use this when you need more control than the tools provide.
274
+ */
275
+ client: (config?: {
276
+ apiKey?: string;
277
+ baseUrl?: string;
278
+ }) => AttessoClient;
279
+ };
280
+ export { createAttessoTools, schemas as attessoSchemas };
281
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,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,276 @@
1
+ "use strict";
2
+ /**
3
+ * Vercel AI SDK Integration for Attesso
4
+ *
5
+ * Provides pre-built tools that instantly give AI agents wallet and identity capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { generateText } from 'ai';
10
+ * import { attesso } from '@attesso/sdk/vercel';
11
+ *
12
+ * const result = await generateText({
13
+ * model: openai('gpt-4o'),
14
+ * tools: attesso.tools(),
15
+ * prompt: 'Book me a flight to NYC under $500',
16
+ * });
17
+ * ```
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.attessoSchemas = exports.attesso = void 0;
21
+ exports.createAttessoTools = createAttessoTools;
22
+ const ai_1 = require("ai");
23
+ const zod_1 = require("zod");
24
+ const client_js_1 = require("../client.js");
25
+ // ============================================================
26
+ // TOOL DEFINITIONS
27
+ // ============================================================
28
+ /**
29
+ * Zod schemas for tool inputs - these are shared with AI models
30
+ */
31
+ const schemas = {
32
+ getMandate: zod_1.z.object({
33
+ mandateId: zod_1.z.string().describe('The unique identifier of the mandate to retrieve'),
34
+ }),
35
+ executePayment: zod_1.z.object({
36
+ mandateId: zod_1.z.string().describe('The mandate ID authorizing this payment'),
37
+ amount: zod_1.z.number().positive().describe('Amount to charge in cents (e.g., 34700 for $347.00)'),
38
+ merchant: zod_1.z.string().describe('Name of the merchant receiving payment'),
39
+ }),
40
+ getPayment: zod_1.z.object({
41
+ paymentId: zod_1.z.string().describe('The unique identifier of the payment to retrieve'),
42
+ }),
43
+ getPassport: zod_1.z.object({
44
+ mandateId: zod_1.z.string().describe('The mandate ID to generate a passport for'),
45
+ }),
46
+ capture: zod_1.z.object({
47
+ paymentId: zod_1.z.string().describe('The payment ID to capture'),
48
+ amount: zod_1.z.number().positive().describe('Final amount to capture in cents (must be <= authorized amount)'),
49
+ metadata: zod_1.z.record(zod_1.z.string()).optional().describe('Optional metadata to attach to the capture'),
50
+ }),
51
+ cancel: zod_1.z.object({
52
+ paymentId: zod_1.z.string().describe('The payment ID to cancel and release funds'),
53
+ }),
54
+ checkBalance: zod_1.z.object({
55
+ mandateId: zod_1.z.string().describe('The mandate ID to check remaining balance for'),
56
+ }),
57
+ empty: zod_1.z.object({}),
58
+ };
59
+ exports.attessoSchemas = schemas;
60
+ // ============================================================
61
+ // ATTESSO TOOLS FACTORY
62
+ // ============================================================
63
+ /**
64
+ * Creates the Attesso tools bundle for Vercel AI SDK.
65
+ *
66
+ * @example Basic usage
67
+ * ```typescript
68
+ * import { generateText } from 'ai';
69
+ * import { attesso } from '@attesso/sdk/vercel';
70
+ *
71
+ * const result = await generateText({
72
+ * model: openai('gpt-4o'),
73
+ * tools: attesso.tools(),
74
+ * prompt: 'Book me a flight to NYC',
75
+ * });
76
+ * ```
77
+ *
78
+ * @example With pre-configured mandate
79
+ * ```typescript
80
+ * const result = await generateText({
81
+ * model: openai('gpt-4o'),
82
+ * tools: attesso.tools({
83
+ * mandateId: 'mandate_xyz',
84
+ * maxAmountPerTransaction: 50000, // $500 cap
85
+ * }),
86
+ * prompt: 'Find and book the best hotel deal',
87
+ * });
88
+ * ```
89
+ */
90
+ function createAttessoTools(config = {}) {
91
+ const client = new client_js_1.AttessoClient({
92
+ apiKey: config.apiKey ?? process.env.ATTESSO_API_KEY,
93
+ baseUrl: config.baseUrl,
94
+ });
95
+ const defaultMandateId = config.mandateId;
96
+ const defaultMerchant = config.merchant;
97
+ const maxAmount = config.maxAmountPerTransaction;
98
+ return {
99
+ /**
100
+ * Get mandate details to check spending limits and status.
101
+ * Use this before making a purchase to verify available funds.
102
+ */
103
+ attesso_get_mandate: (0, ai_1.tool)({
104
+ description: 'Get details about a spending mandate including the maximum amount, status, and restrictions. ' +
105
+ 'Use this to check how much money is available before making a purchase.',
106
+ parameters: defaultMandateId ? schemas.empty : schemas.getMandate,
107
+ execute: async (input) => {
108
+ const mandateId = defaultMandateId ?? input.mandateId;
109
+ if (!mandateId) {
110
+ throw new client_js_1.AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
111
+ }
112
+ return client.getMandate(mandateId);
113
+ },
114
+ }),
115
+ /**
116
+ * Execute a payment against a mandate.
117
+ * This is the main tool for making purchases.
118
+ */
119
+ attesso_pay: (0, ai_1.tool)({
120
+ description: 'Execute a payment to purchase something. The payment will be charged against the user\'s pre-authorized mandate. ' +
121
+ 'Amount must be in cents (e.g., 34700 for $347.00). ' +
122
+ 'Only call this after finding the best deal and confirming the price.',
123
+ parameters: defaultMandateId && defaultMerchant
124
+ ? zod_1.z.object({ amount: schemas.executePayment.shape.amount })
125
+ : defaultMandateId
126
+ ? zod_1.z.object({
127
+ amount: schemas.executePayment.shape.amount,
128
+ merchant: schemas.executePayment.shape.merchant,
129
+ })
130
+ : defaultMerchant
131
+ ? zod_1.z.object({
132
+ mandateId: schemas.executePayment.shape.mandateId,
133
+ amount: schemas.executePayment.shape.amount,
134
+ })
135
+ : schemas.executePayment,
136
+ execute: async (input) => {
137
+ const mandateId = defaultMandateId ?? input.mandateId;
138
+ const merchant = defaultMerchant ?? input.merchant;
139
+ const { amount } = input;
140
+ if (!mandateId) {
141
+ throw new client_js_1.AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
142
+ }
143
+ if (!merchant) {
144
+ throw new client_js_1.AttessoError('MERCHANT_MISMATCH', 'merchant is required');
145
+ }
146
+ // Apply optional transaction cap
147
+ if (maxAmount && amount > maxAmount) {
148
+ throw new client_js_1.AttessoError('AMOUNT_EXCEEDS_LIMIT', `Amount ${amount} exceeds maximum allowed per transaction (${maxAmount})`);
149
+ }
150
+ return client.executePayment({ mandateId, amount, merchant });
151
+ },
152
+ }),
153
+ /**
154
+ * Get payment status and details.
155
+ */
156
+ attesso_get_payment: (0, ai_1.tool)({
157
+ description: 'Get the status and details of a specific payment. ' +
158
+ 'Use this to verify a payment was successful or check its current status.',
159
+ parameters: schemas.getPayment,
160
+ execute: async ({ paymentId }) => {
161
+ return client.getPayment(paymentId);
162
+ },
163
+ }),
164
+ /**
165
+ * Get a passport token for authenticated merchant access.
166
+ * This proves to merchants that the agent has authorized spending power.
167
+ */
168
+ attesso_get_passport: (0, ai_1.tool)({
169
+ description: 'Get a passport token that proves authorized spending power to merchants. ' +
170
+ 'Some merchants require this for fast-lane checkout without additional verification. ' +
171
+ 'The passport includes solvency proof and reputation data.',
172
+ parameters: defaultMandateId ? schemas.empty : schemas.getPassport,
173
+ execute: async (input) => {
174
+ const mandateId = defaultMandateId ?? input.mandateId;
175
+ if (!mandateId) {
176
+ throw new client_js_1.AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
177
+ }
178
+ return client.getPassport(mandateId);
179
+ },
180
+ }),
181
+ /**
182
+ * Capture a previously authorized payment.
183
+ * Use this in auth/capture flow when the final price is known.
184
+ */
185
+ attesso_capture: (0, ai_1.tool)({
186
+ description: 'Capture a previously authorized payment with the final amount. ' +
187
+ 'Use this when the exact price is known (e.g., after finding the best flight). ' +
188
+ 'The capture amount must be less than or equal to the authorized amount. ' +
189
+ 'Any excess funds are automatically released.',
190
+ parameters: schemas.capture,
191
+ execute: async ({ paymentId, amount, metadata }) => {
192
+ return client.capture(paymentId, { amount, metadata });
193
+ },
194
+ }),
195
+ /**
196
+ * Cancel an authorization and release held funds.
197
+ * Use this when a purchase won't proceed.
198
+ */
199
+ attesso_cancel: (0, ai_1.tool)({
200
+ description: 'Cancel an authorization and release the held funds back to the user. ' +
201
+ 'Use this when a purchase won\'t proceed (e.g., no suitable options found, user changed mind). ' +
202
+ 'Always cancel unused authorizations promptly.',
203
+ parameters: schemas.cancel,
204
+ execute: async ({ paymentId }) => {
205
+ return client.cancel(paymentId);
206
+ },
207
+ }),
208
+ /**
209
+ * Check remaining balance on a mandate.
210
+ * Convenience tool that wraps getMandate for quick balance checks.
211
+ */
212
+ attesso_check_balance: (0, ai_1.tool)({
213
+ description: 'Quickly check how much money is available to spend on a mandate. ' +
214
+ 'Returns the maximum amount and current status.',
215
+ parameters: defaultMandateId ? schemas.empty : schemas.checkBalance,
216
+ execute: async (input) => {
217
+ const mandateId = defaultMandateId ?? input.mandateId;
218
+ if (!mandateId) {
219
+ throw new client_js_1.AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
220
+ }
221
+ const mandate = await client.getMandate(mandateId);
222
+ return {
223
+ available: mandate.maxAmount,
224
+ currency: mandate.currency,
225
+ status: mandate.status,
226
+ };
227
+ },
228
+ }),
229
+ };
230
+ }
231
+ // ============================================================
232
+ // MAIN EXPORT
233
+ // ============================================================
234
+ /**
235
+ * Attesso integration for Vercel AI SDK.
236
+ *
237
+ * @example One-import usage
238
+ * ```typescript
239
+ * import { generateText } from 'ai';
240
+ * import { attesso } from '@attesso/sdk/vercel';
241
+ *
242
+ * const result = await generateText({
243
+ * model: openai('gpt-4o'),
244
+ * tools: attesso.tools(),
245
+ * prompt: 'Book me a flight to NYC under $500',
246
+ * });
247
+ * ```
248
+ *
249
+ * @example With configuration
250
+ * ```typescript
251
+ * const result = await generateText({
252
+ * model: openai('gpt-4o'),
253
+ * tools: attesso.tools({
254
+ * mandateId: mandate.id,
255
+ * merchant: 'United Airlines',
256
+ * }),
257
+ * prompt: 'Find and book the cheapest flight',
258
+ * });
259
+ * ```
260
+ */
261
+ exports.attesso = {
262
+ /**
263
+ * Create Attesso tools for use with Vercel AI SDK.
264
+ * Returns a tool bundle that can be spread into the tools object.
265
+ */
266
+ tools: createAttessoTools,
267
+ /**
268
+ * Create an Attesso client for direct API access.
269
+ * Use this when you need more control than the tools provide.
270
+ */
271
+ client: (config) => new client_js_1.AttessoClient({
272
+ apiKey: config?.apiKey ?? process.env.ATTESSO_API_KEY,
273
+ baseUrl: config?.baseUrl,
274
+ }),
275
+ };
276
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AA8UM,gDAAkB;AA5U3B,2BAA0B;AAC1B,6BAAwB;AACxB,4CAA2D;AA2C3D,+DAA+D;AAC/D,mB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H,MAAM,EAAE,CAAC,MAA8C,EAAE,EAAE,CACzD,IAAI,yBAAa,CAAC;QAChB,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;QACrD,OAAO,EAAE,MAAM,EAAE,OAAO;KACzB,CAAC;CACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@attesso/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Attesso SDK for autonomous commerce - enable AI agents to make purchases",
5
+ "author": "Attesso",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/attesso/attesso"
10
+ },
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.js"
28
+ },
29
+ "./vercel": {
30
+ "types": "./dist/vercel/index.d.ts",
31
+ "import": "./dist/vercel/index.js",
32
+ "require": "./dist/vercel/index.js"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "build": "tsc",
37
+ "dev": "tsc --watch",
38
+ "clean": "rm -rf dist",
39
+ "test": "vitest run"
40
+ },
41
+ "keywords": [
42
+ "attesso",
43
+ "payments",
44
+ "ai-agents",
45
+ "autonomous-commerce",
46
+ "open-banking",
47
+ "vercel-ai-sdk",
48
+ "ai-tools"
49
+ ],
50
+ "dependencies": {
51
+ "@attesso/gatekeeper": "workspace:*",
52
+ "@attesso/types": "workspace:*"
53
+ },
54
+ "peerDependencies": {
55
+ "ai": ">=3.0.0",
56
+ "zod": ">=3.0.0"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "ai": {
60
+ "optional": true
61
+ },
62
+ "zod": {
63
+ "optional": true
64
+ }
65
+ },
66
+ "devDependencies": {
67
+ "ai": "^4.0.0",
68
+ "typescript": "^5.7.0",
69
+ "vitest": "^2.1.0",
70
+ "zod": "^3.23.0"
71
+ }
72
+ }