@attesso/sdk 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +17 -50
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -60
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/vercel/index.d.ts +32 -114
- package/dist/vercel/index.d.ts.map +1 -1
- package/dist/vercel/index.js +39 -111
- package/dist/vercel/index.js.map +1 -1
- package/package.json +6 -7
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MandateResponse, PaymentResponse,
|
|
1
|
+
import type { MandateResponse, PaymentResponse, IssueCardResponse, CreateMandateRequestInput, CreateMandateRequestResponse, MandateRequestDetails } from '@attesso/types';
|
|
2
2
|
export interface AttessoClientConfig {
|
|
3
3
|
apiKey?: string;
|
|
4
4
|
apiUrl?: string;
|
|
@@ -18,14 +18,11 @@ export interface AttessoClientConfig {
|
|
|
18
18
|
*/
|
|
19
19
|
allowedOrigins?: string[];
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
22
|
-
mandateId: string;
|
|
21
|
+
export interface IssueCardOptions {
|
|
23
22
|
amount: number;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
amount: number;
|
|
28
|
-
metadata?: Record<string, string>;
|
|
23
|
+
ttlSeconds?: number;
|
|
24
|
+
allowedMccs?: string[];
|
|
25
|
+
blockedMccs?: string[];
|
|
29
26
|
}
|
|
30
27
|
export declare class AttessoClient {
|
|
31
28
|
private apiKey;
|
|
@@ -57,61 +54,31 @@ export declare class AttessoClient {
|
|
|
57
54
|
*/
|
|
58
55
|
getMandate(mandateId: string): Promise<MandateResponse>;
|
|
59
56
|
/**
|
|
60
|
-
*
|
|
57
|
+
* Issue an ephemeral virtual card from a standing mandate.
|
|
61
58
|
* This is the main method bots use to make purchases.
|
|
62
59
|
*
|
|
60
|
+
* The card is created with a TTL and auto-destructs after use or timeout.
|
|
61
|
+
* Money is auth-held at issue time and captured when the merchant charges.
|
|
62
|
+
*
|
|
63
|
+
* @param mandateId - The mandate ID to issue a card from
|
|
64
|
+
* @param options - Issue options including amount and TTL
|
|
65
|
+
*
|
|
63
66
|
* @example
|
|
64
67
|
* ```typescript
|
|
65
|
-
* const
|
|
66
|
-
*
|
|
67
|
-
* const payment = await aegis.executePayment({
|
|
68
|
-
* mandateId: 'mandate_xyz',
|
|
68
|
+
* const card = await attesso.issueCard('mandate_xyz', {
|
|
69
69
|
* amount: 75000, // $750.00 in cents
|
|
70
|
-
*
|
|
70
|
+
* ttlSeconds: 300, // 5 minute TTL
|
|
71
71
|
* });
|
|
72
72
|
*
|
|
73
|
-
* console.log(`
|
|
73
|
+
* console.log(`Card ${card.cardId} number: ${card.number}`);
|
|
74
|
+
* console.log(`Expires at: ${card.expiresAt}`);
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
|
-
|
|
77
|
+
issueCard(mandateId: string, options: IssueCardOptions): Promise<IssueCardResponse>;
|
|
77
78
|
/**
|
|
78
79
|
* Get a payment by ID.
|
|
79
80
|
*/
|
|
80
81
|
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
82
|
/**
|
|
116
83
|
* Create a mandate request and get an approval URL.
|
|
117
84
|
* Send this URL to the user so they can authorize the spending.
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAGf,iBAAiB,EACjB,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACtB,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,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM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EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,EAAE,CAAC;gBAEb,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE;CAS5D"}
|
package/dist/client.js
CHANGED
|
@@ -110,29 +110,28 @@ class AttessoClient {
|
|
|
110
110
|
return this.request('GET', `/v1/mandates/${mandateId}`);
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* Issue an ephemeral virtual card from a standing mandate.
|
|
114
114
|
* This is the main method bots use to make purchases.
|
|
115
115
|
*
|
|
116
|
+
* The card is created with a TTL and auto-destructs after use or timeout.
|
|
117
|
+
* Money is auth-held at issue time and captured when the merchant charges.
|
|
118
|
+
*
|
|
119
|
+
* @param mandateId - The mandate ID to issue a card from
|
|
120
|
+
* @param options - Issue options including amount and TTL
|
|
121
|
+
*
|
|
116
122
|
* @example
|
|
117
123
|
* ```typescript
|
|
118
|
-
* const
|
|
119
|
-
*
|
|
120
|
-
* const payment = await aegis.executePayment({
|
|
121
|
-
* mandateId: 'mandate_xyz',
|
|
124
|
+
* const card = await attesso.issueCard('mandate_xyz', {
|
|
122
125
|
* amount: 75000, // $750.00 in cents
|
|
123
|
-
*
|
|
126
|
+
* ttlSeconds: 300, // 5 minute TTL
|
|
124
127
|
* });
|
|
125
128
|
*
|
|
126
|
-
* console.log(`
|
|
129
|
+
* console.log(`Card ${card.cardId} number: ${card.number}`);
|
|
130
|
+
* console.log(`Expires at: ${card.expiresAt}`);
|
|
127
131
|
* ```
|
|
128
132
|
*/
|
|
129
|
-
async
|
|
130
|
-
|
|
131
|
-
mandateId: options.mandateId,
|
|
132
|
-
amount: options.amount,
|
|
133
|
-
merchant: options.merchant,
|
|
134
|
-
};
|
|
135
|
-
return this.request('POST', '/v1/payments', request);
|
|
133
|
+
async issueCard(mandateId, options) {
|
|
134
|
+
return this.request('POST', `/v1/mandates/${mandateId}/issue`, options);
|
|
136
135
|
}
|
|
137
136
|
/**
|
|
138
137
|
* Get a payment by ID.
|
|
@@ -140,52 +139,6 @@ class AttessoClient {
|
|
|
140
139
|
async getPayment(paymentId) {
|
|
141
140
|
return this.request('GET', `/v1/payments/${paymentId}`);
|
|
142
141
|
}
|
|
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
142
|
// ============================================================
|
|
190
143
|
// MANDATE REQUESTS - Async authorization flow
|
|
191
144
|
// Agent creates a request, user approves via link, agent gets notified
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAsCA,MAAa,aAAa;IAChB,MAAM,CAAqB;IAC3B,OAAO,CAAS;IAChB,cAAc,CAAuB;IAE7C,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,IAAI,yBAAyB,CAAC;QAC5E,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACK,eAAe,CAAC,MAAe;QACrC,IAAI,CAAC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,qEAAqE;QACrE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;gBACxC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACK,aAAa,CAAC,MAAc,EAAE,OAAe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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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { AttessoClient, AttessoError, OriginNotAllowedError } from './client.js';
|
|
2
|
-
export type { AttessoClientConfig,
|
|
3
|
-
export {
|
|
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, MandateRequestStatus, CreateMandateRequestInput, CreateMandateRequestResponse, MandateRequestDetails, MandateRequestEventType, MandateRequestWebhookPayload, } from '@attesso/types';
|
|
2
|
+
export type { AttessoClientConfig, IssueCardOptions, } from './client.js';
|
|
3
|
+
export type { Mandate, MandateResponse, MandateStatus, Payment, PaymentResponse, PaymentStatus, PaymentError, PaymentErrorCode, IssueCardRequest, IssueCardResponse, MandateRequestStatus, CreateMandateRequestInput, CreateMandateRequestResponse, MandateRequestDetails, MandateRequestEventType, MandateRequestWebhookPayload, } from '@attesso/types';
|
|
6
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,OAAO,EACP,eAAe,EACf,aAAa,EACb,OAAO,EACP,eAAe,EACf,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAEjB,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OriginNotAllowedError = exports.AttessoError = exports.AttessoClient = void 0;
|
|
4
4
|
var client_js_1 = require("./client.js");
|
|
5
5
|
Object.defineProperty(exports, "AttessoClient", { enumerable: true, get: function () { return client_js_1.AttessoClient; } });
|
|
6
6
|
Object.defineProperty(exports, "AttessoError", { enumerable: true, get: function () { return client_js_1.AttessoError; } });
|
|
7
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
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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
|
|
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"}
|
package/dist/vercel/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vercel AI SDK Integration for Attesso
|
|
3
3
|
*
|
|
4
|
-
* Provides pre-built tools that instantly give AI agents payment
|
|
4
|
+
* Provides pre-built tools that instantly give AI agents payment capabilities.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { z } from 'zod';
|
|
19
19
|
import { AttessoClient } from '../client.js';
|
|
20
|
-
import type { MandateResponse,
|
|
20
|
+
import type { MandateResponse, IssueCardResponse } from '@attesso/types';
|
|
21
21
|
export interface AttessoToolsConfig {
|
|
22
22
|
/**
|
|
23
23
|
* Attesso API key. Falls back to ATTESSO_API_KEY env var.
|
|
@@ -34,11 +34,7 @@ export interface AttessoToolsConfig {
|
|
|
34
34
|
*/
|
|
35
35
|
mandateId?: string;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
merchant?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Maximum amount (in cents) the agent can spend per transaction.
|
|
37
|
+
* Maximum amount (in cents) the agent can spend per card issuance.
|
|
42
38
|
* Provides an additional guardrail on top of mandate limits.
|
|
43
39
|
*/
|
|
44
40
|
maxAmountPerTransaction?: number;
|
|
@@ -54,54 +50,27 @@ declare const schemas: {
|
|
|
54
50
|
}, {
|
|
55
51
|
mandateId: string;
|
|
56
52
|
}>;
|
|
57
|
-
|
|
53
|
+
issueCard: z.ZodObject<{
|
|
58
54
|
mandateId: z.ZodString;
|
|
59
55
|
amount: z.ZodNumber;
|
|
60
|
-
|
|
56
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
61
57
|
}, "strip", z.ZodTypeAny, {
|
|
62
58
|
mandateId: string;
|
|
63
59
|
amount: number;
|
|
64
|
-
|
|
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;
|
|
60
|
+
ttlSeconds?: number | undefined;
|
|
81
61
|
}, {
|
|
82
62
|
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
63
|
amount: number;
|
|
94
|
-
|
|
95
|
-
metadata?: Record<string, string> | undefined;
|
|
64
|
+
ttlSeconds?: number | undefined;
|
|
96
65
|
}>;
|
|
97
|
-
|
|
98
|
-
|
|
66
|
+
getCard: z.ZodObject<{
|
|
67
|
+
cardId: z.ZodString;
|
|
99
68
|
}, "strip", z.ZodTypeAny, {
|
|
100
|
-
|
|
69
|
+
cardId: string;
|
|
101
70
|
}, {
|
|
102
|
-
|
|
71
|
+
cardId: string;
|
|
103
72
|
}>;
|
|
104
|
-
|
|
73
|
+
revokeMandate: z.ZodObject<{
|
|
105
74
|
mandateId: z.ZodString;
|
|
106
75
|
}, "strip", z.ZodTypeAny, {
|
|
107
76
|
mandateId: string;
|
|
@@ -140,99 +109,49 @@ declare const schemas: {
|
|
|
140
109
|
declare function createAttessoTools(config?: AttessoToolsConfig): {
|
|
141
110
|
/**
|
|
142
111
|
* Get mandate details to check spending limits and status.
|
|
143
|
-
* Use this before
|
|
112
|
+
* Use this before issuing a card to verify the mandate is active.
|
|
144
113
|
*/
|
|
145
114
|
attesso_get_mandate: import("ai").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, MandateResponse> & {
|
|
146
115
|
execute: (args: {}, options: import("ai").ToolExecutionOptions) => PromiseLike<MandateResponse>;
|
|
147
116
|
};
|
|
148
117
|
/**
|
|
149
|
-
*
|
|
118
|
+
* Issue an ephemeral virtual card from a standing mandate.
|
|
150
119
|
* This is the main tool for making purchases.
|
|
151
120
|
*/
|
|
152
|
-
|
|
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;
|
|
121
|
+
attesso_issue_card: import("ai").Tool<z.ZodObject<{
|
|
190
122
|
amount: z.ZodNumber;
|
|
191
|
-
|
|
123
|
+
ttlSeconds: z.ZodOptional<z.ZodNumber>;
|
|
192
124
|
}, "strip", z.ZodTypeAny, {
|
|
193
125
|
amount: number;
|
|
194
|
-
|
|
195
|
-
metadata?: Record<string, string> | undefined;
|
|
126
|
+
ttlSeconds?: number | undefined;
|
|
196
127
|
}, {
|
|
197
128
|
amount: number;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}>, CapturePaymentResponse> & {
|
|
129
|
+
ttlSeconds?: number | undefined;
|
|
130
|
+
}>, IssueCardResponse> & {
|
|
201
131
|
execute: (args: {
|
|
202
132
|
amount: number;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}, options: import("ai").ToolExecutionOptions) => PromiseLike<CapturePaymentResponse>;
|
|
133
|
+
ttlSeconds?: number | undefined;
|
|
134
|
+
}, options: import("ai").ToolExecutionOptions) => PromiseLike<IssueCardResponse>;
|
|
206
135
|
};
|
|
207
136
|
/**
|
|
208
|
-
*
|
|
209
|
-
* Use this when a purchase won't proceed.
|
|
137
|
+
* Get card status and details.
|
|
210
138
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
139
|
+
attesso_get_card: import("ai").Tool<z.ZodObject<{
|
|
140
|
+
cardId: z.ZodString;
|
|
213
141
|
}, "strip", z.ZodTypeAny, {
|
|
214
|
-
|
|
142
|
+
cardId: string;
|
|
215
143
|
}, {
|
|
216
|
-
|
|
217
|
-
}>,
|
|
144
|
+
cardId: string;
|
|
145
|
+
}>, unknown> & {
|
|
218
146
|
execute: (args: {
|
|
219
|
-
|
|
220
|
-
}, options: import("ai").ToolExecutionOptions) => PromiseLike<
|
|
147
|
+
cardId: string;
|
|
148
|
+
}, options: import("ai").ToolExecutionOptions) => PromiseLike<unknown>;
|
|
221
149
|
};
|
|
222
150
|
/**
|
|
223
|
-
*
|
|
224
|
-
* Convenience tool that wraps getMandate for quick balance checks.
|
|
151
|
+
* Revoke a mandate so it can no longer be used.
|
|
225
152
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
}>;
|
|
153
|
+
attesso_revoke_mandate: import("ai").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, void> & {
|
|
154
|
+
execute: (args: {}, options: import("ai").ToolExecutionOptions) => PromiseLike<void>;
|
|
236
155
|
};
|
|
237
156
|
};
|
|
238
157
|
/**
|
|
@@ -256,7 +175,6 @@ declare function createAttessoTools(config?: AttessoToolsConfig): {
|
|
|
256
175
|
* model: openai('gpt-4o'),
|
|
257
176
|
* tools: attesso.tools({
|
|
258
177
|
* mandateId: mandate.id,
|
|
259
|
-
* merchant: 'United Airlines',
|
|
260
178
|
* }),
|
|
261
179
|
* prompt: 'Find and book the cheapest flight',
|
|
262
180
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAMD;;GAEG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBZ,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iBAAS,kBAAkB,CAAC,MAAM,GAAE,kBAAuB;IAUvD;;;OAGG;;;;IAeH;;;OAGG;;;;;;;;;;;;;;;;IAkCH;;OAEG;;;;;;;;;;;;IAWH;;OAEG;;;;EAeN;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,OAAO;IAClB;;;OAGG;;IAGH;;;OAGG;sBACe;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAKxD,CAAC;AAGF,OAAO,EAAE,kBAAkB,EAAE,OAAO,IAAI,cAAc,EAAE,CAAC"}
|
package/dist/vercel/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Vercel AI SDK Integration for Attesso
|
|
4
4
|
*
|
|
5
|
-
* Provides pre-built tools that instantly give AI agents payment
|
|
5
|
+
* Provides pre-built tools that instantly give AI agents payment capabilities.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
@@ -32,27 +32,16 @@ const schemas = {
|
|
|
32
32
|
getMandate: zod_1.z.object({
|
|
33
33
|
mandateId: zod_1.z.string().describe('The unique identifier of the mandate to retrieve'),
|
|
34
34
|
}),
|
|
35
|
-
|
|
36
|
-
mandateId: zod_1.z.string().describe('The mandate ID
|
|
37
|
-
amount: zod_1.z.number().positive().describe('Amount
|
|
38
|
-
|
|
35
|
+
issueCard: zod_1.z.object({
|
|
36
|
+
mandateId: zod_1.z.string().describe('The mandate ID to issue an ephemeral card from'),
|
|
37
|
+
amount: zod_1.z.number().positive().describe('Amount in cents the agent wants to spend (e.g., 34700 for $347.00)'),
|
|
38
|
+
ttlSeconds: zod_1.z.number().int().min(60).max(900).optional().describe('Card time-to-live in seconds (60-900, default 300)'),
|
|
39
39
|
}),
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
getCard: zod_1.z.object({
|
|
41
|
+
cardId: zod_1.z.string().describe('The unique identifier of the card to retrieve'),
|
|
42
42
|
}),
|
|
43
|
-
|
|
44
|
-
mandateId: zod_1.z.string().describe('The mandate ID to
|
|
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'),
|
|
43
|
+
revokeMandate: zod_1.z.object({
|
|
44
|
+
mandateId: zod_1.z.string().describe('The mandate ID to revoke'),
|
|
56
45
|
}),
|
|
57
46
|
empty: zod_1.z.object({}),
|
|
58
47
|
};
|
|
@@ -93,16 +82,15 @@ function createAttessoTools(config = {}) {
|
|
|
93
82
|
baseUrl: config.baseUrl,
|
|
94
83
|
});
|
|
95
84
|
const defaultMandateId = config.mandateId;
|
|
96
|
-
const defaultMerchant = config.merchant;
|
|
97
85
|
const maxAmount = config.maxAmountPerTransaction;
|
|
98
86
|
return {
|
|
99
87
|
/**
|
|
100
88
|
* Get mandate details to check spending limits and status.
|
|
101
|
-
* Use this before
|
|
89
|
+
* Use this before issuing a card to verify the mandate is active.
|
|
102
90
|
*/
|
|
103
91
|
attesso_get_mandate: (0, ai_1.tool)({
|
|
104
|
-
description: 'Get details about a spending mandate including the
|
|
105
|
-
'Use this to check how much money is available before
|
|
92
|
+
description: 'Get details about a spending mandate including the spending limit, status, and restrictions. ' +
|
|
93
|
+
'Use this to check how much money is available before issuing a card.',
|
|
106
94
|
parameters: defaultMandateId ? schemas.empty : schemas.getMandate,
|
|
107
95
|
execute: async (input) => {
|
|
108
96
|
const mandateId = defaultMandateId ?? input.mandateId;
|
|
@@ -113,117 +101,58 @@ function createAttessoTools(config = {}) {
|
|
|
113
101
|
},
|
|
114
102
|
}),
|
|
115
103
|
/**
|
|
116
|
-
*
|
|
104
|
+
* Issue an ephemeral virtual card from a standing mandate.
|
|
117
105
|
* This is the main tool for making purchases.
|
|
118
106
|
*/
|
|
119
|
-
|
|
120
|
-
description: '
|
|
107
|
+
attesso_issue_card: (0, ai_1.tool)({
|
|
108
|
+
description: 'Issue an ephemeral virtual card from a standing mandate. ' +
|
|
109
|
+
'This auth-holds the user\'s payment method and creates a card with a TTL. ' +
|
|
110
|
+
'The card auto-destructs after use or when the TTL expires. ' +
|
|
121
111
|
'Amount must be in cents (e.g., 34700 for $347.00). ' +
|
|
122
|
-
'Only call this
|
|
123
|
-
parameters: defaultMandateId
|
|
124
|
-
? zod_1.z.object({
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
})
|
|
130
|
-
: defaultMerchant
|
|
131
|
-
? zod_1.z.object({
|
|
132
|
-
mandateId: schemas.executePayment.shape.mandateId,
|
|
133
|
-
amount: schemas.executePayment.shape.amount,
|
|
134
|
-
})
|
|
135
|
-
: schemas.executePayment,
|
|
112
|
+
'Only call this when you are ready to make a purchase.',
|
|
113
|
+
parameters: defaultMandateId
|
|
114
|
+
? zod_1.z.object({
|
|
115
|
+
amount: schemas.issueCard.shape.amount,
|
|
116
|
+
ttlSeconds: schemas.issueCard.shape.ttlSeconds,
|
|
117
|
+
})
|
|
118
|
+
: schemas.issueCard,
|
|
136
119
|
execute: async (input) => {
|
|
137
120
|
const mandateId = defaultMandateId ?? input.mandateId;
|
|
138
|
-
const
|
|
139
|
-
const { amount } = input;
|
|
121
|
+
const { amount, ttlSeconds } = input;
|
|
140
122
|
if (!mandateId) {
|
|
141
123
|
throw new client_js_1.AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
|
|
142
124
|
}
|
|
143
|
-
if (!merchant) {
|
|
144
|
-
throw new client_js_1.AttessoError('MERCHANT_MISMATCH', 'merchant is required');
|
|
145
|
-
}
|
|
146
125
|
// Apply optional transaction cap
|
|
147
126
|
if (maxAmount && amount > maxAmount) {
|
|
148
127
|
throw new client_js_1.AttessoError('AMOUNT_EXCEEDS_LIMIT', `Amount ${amount} exceeds maximum allowed per transaction (${maxAmount})`);
|
|
149
128
|
}
|
|
150
|
-
return client.
|
|
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 risk attestation 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 });
|
|
129
|
+
return client.issueCard(mandateId, { amount, ttlSeconds });
|
|
193
130
|
},
|
|
194
131
|
}),
|
|
195
132
|
/**
|
|
196
|
-
*
|
|
197
|
-
* Use this when a purchase won't proceed.
|
|
133
|
+
* Get card status and details.
|
|
198
134
|
*/
|
|
199
|
-
|
|
200
|
-
description: '
|
|
201
|
-
'Use this
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return client.cancel(paymentId);
|
|
135
|
+
attesso_get_card: (0, ai_1.tool)({
|
|
136
|
+
description: 'Get the status and details of an issued ephemeral card. ' +
|
|
137
|
+
'Use this to check if a card is still active or has been used.',
|
|
138
|
+
parameters: schemas.getCard,
|
|
139
|
+
execute: async ({ cardId }) => {
|
|
140
|
+
return client.request('GET', `/v1/cards/${cardId}`);
|
|
206
141
|
},
|
|
207
142
|
}),
|
|
208
143
|
/**
|
|
209
|
-
*
|
|
210
|
-
* Convenience tool that wraps getMandate for quick balance checks.
|
|
144
|
+
* Revoke a mandate so it can no longer be used.
|
|
211
145
|
*/
|
|
212
|
-
|
|
213
|
-
description: '
|
|
214
|
-
'
|
|
215
|
-
parameters: defaultMandateId ? schemas.empty : schemas.
|
|
146
|
+
attesso_revoke_mandate: (0, ai_1.tool)({
|
|
147
|
+
description: 'Revoke a mandate so it can no longer be used to issue cards. ' +
|
|
148
|
+
'Use this when the mandate is no longer needed.',
|
|
149
|
+
parameters: defaultMandateId ? schemas.empty : schemas.revokeMandate,
|
|
216
150
|
execute: async (input) => {
|
|
217
151
|
const mandateId = defaultMandateId ?? input.mandateId;
|
|
218
152
|
if (!mandateId) {
|
|
219
153
|
throw new client_js_1.AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
|
|
220
154
|
}
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
available: mandate.maxAmount,
|
|
224
|
-
currency: mandate.currency,
|
|
225
|
-
status: mandate.status,
|
|
226
|
-
};
|
|
155
|
+
await client.request('DELETE', `/v1/mandates/${mandateId}`);
|
|
227
156
|
},
|
|
228
157
|
}),
|
|
229
158
|
};
|
|
@@ -252,7 +181,6 @@ function createAttessoTools(config = {}) {
|
|
|
252
181
|
* model: openai('gpt-4o'),
|
|
253
182
|
* tools: attesso.tools({
|
|
254
183
|
* mandateId: mandate.id,
|
|
255
|
-
* merchant: 'United Airlines',
|
|
256
184
|
* }),
|
|
257
185
|
* prompt: 'Find and book the cheapest flight',
|
|
258
186
|
* });
|
package/dist/vercel/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vercel/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAqPM,gDAAkB;AAnP3B,2BAA0B;AAC1B,6BAAwB;AACxB,4CAA2D;AAmC3D,+DAA+D;AAC/D,mBAAmB;AACnB,+DAA+D;AAE/D;;GAEG;AACH,MAAM,OAAO,GAAG;IACd,UAAU,EAAE,OAAC,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;KACnF,CAAC;IAEF,SAAS,EAAE,OAAC,CAAC,MAAM,CAAC;QAClB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;QAChF,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oEAAoE,CAAC;QAC5G,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;KACxH,CAAC;IAEF,OAAO,EAAE,OAAC,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AAE,CAAC,CAAC;YAC/D,CAAC;SACF,CAAC;QAEF;;WAEG;QACH,sBAAsB,EAAE,IAAA,SAAI,EAAC;YAC3B,WAAW,EACT,+DAA+D;gBAC/D,gDAAgD;YAClD,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa;YACpE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAiB,EAAE;gBACtC,MAAM,SAAS,GAAG,gBAAgB,IAAK,KAAgC,CAAC,SAAS,CAAC;gBAClF,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,IAAI,wBAAY,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;gBACvE,CAAC;gBACD,MAAO,MAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,SAAS,EAAE,CAAC,CAAC;YACvE,CAAC;SACF,CAAC;KACH,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,cAAc;AACd,+DAA+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACU,QAAA,OAAO,GAAG;IACrB;;;OAGG;IACH,KAAK,EAAE,kBAAkB;IAEzB;;;OAGG;IACH,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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attesso/sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "TypeScript SDK for the Attesso API — create mandates, issue virtual cards, and manage payments for AI agents.",
|
|
5
5
|
"author": "Attesso",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -40,15 +40,14 @@
|
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"attesso",
|
|
43
|
-
"
|
|
43
|
+
"sdk",
|
|
44
|
+
"ai-agents",
|
|
44
45
|
"mandates",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"hardware-attestation",
|
|
46
|
+
"virtual-cards",
|
|
47
|
+
"payments",
|
|
48
48
|
"vercel-ai-sdk"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@attesso/gatekeeper": "workspace:*",
|
|
52
51
|
"@attesso/types": "workspace:*"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|