@attesso/sdk 1.0.0 → 1.0.1
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 +36 -147
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
# @attesso/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Financial infrastructure for AI agents. Programmatic card issuing with hardware-bound biometric authorization.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install @attesso/sdk
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
## What
|
|
9
|
+
## What is Attesso?
|
|
10
10
|
|
|
11
|
-
AI agents
|
|
11
|
+
Attesso provides scoped, ephemeral credentials for AI agents. Users authorize via FIDO2 assertion, and agents receive time-limited cards with spend constraints. Revocation is immediate. All credentials are bound to hardware attestation.
|
|
12
12
|
|
|
13
|
-
|
|
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.
|
|
13
|
+
**No credit cards are exposed to agents.** Agents receive mandate IDs and can only transact within user-defined limits.
|
|
19
14
|
|
|
20
15
|
## Quick Start
|
|
21
16
|
|
|
@@ -26,60 +21,34 @@ const client = new AttessoClient({
|
|
|
26
21
|
apiKey: process.env.ATTESSO_API_KEY,
|
|
27
22
|
});
|
|
28
23
|
|
|
29
|
-
// Check
|
|
24
|
+
// Check spending constraints
|
|
30
25
|
const mandate = await client.getMandate('mandate_xyz');
|
|
31
|
-
console.log(`
|
|
26
|
+
console.log(`Authorized: $${mandate.maxAmount / 100}`);
|
|
32
27
|
|
|
33
|
-
// Execute payment
|
|
28
|
+
// Execute payment within constraints
|
|
34
29
|
const payment = await client.executePayment({
|
|
35
30
|
mandateId: 'mandate_xyz',
|
|
36
31
|
amount: 34700, // $347.00
|
|
37
32
|
merchant: 'United Airlines',
|
|
38
33
|
});
|
|
39
34
|
|
|
40
|
-
// Get
|
|
35
|
+
// Get passport for merchant verification
|
|
41
36
|
const passport = await client.getPassport('mandate_xyz');
|
|
42
37
|
```
|
|
43
38
|
|
|
44
|
-
##
|
|
39
|
+
## Authorization Flow
|
|
45
40
|
|
|
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
41
|
```
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
42
|
+
01. Link Delivery Agent generates authorization URL. User receives via any channel.
|
|
43
|
+
02. FIDO2 Assertion Browser invokes WebAuthn API. Authenticator signs in Secure Enclave.
|
|
44
|
+
03. Agent Execution Agent receives mandate ID. Operates within authorized constraints.
|
|
45
|
+
04. Capture Agent calls capture() with final amount. Excess authorization released.
|
|
46
|
+
05. Settlement Transaction settles via Stripe. Event dispatched to webhook.
|
|
47
|
+
```
|
|
79
48
|
|
|
80
49
|
## Vercel AI SDK Integration
|
|
81
50
|
|
|
82
|
-
|
|
51
|
+
Inject payment capabilities into any agent runtime:
|
|
83
52
|
|
|
84
53
|
```typescript
|
|
85
54
|
import { generateText } from 'ai';
|
|
@@ -88,7 +57,7 @@ import { attesso } from '@attesso/sdk/vercel';
|
|
|
88
57
|
const result = await generateText({
|
|
89
58
|
model: openai('gpt-4o'),
|
|
90
59
|
tools: attesso.tools(),
|
|
91
|
-
prompt: 'Book
|
|
60
|
+
prompt: 'Book cheapest flight to NYC',
|
|
92
61
|
});
|
|
93
62
|
```
|
|
94
63
|
|
|
@@ -97,10 +66,10 @@ const result = await generateText({
|
|
|
97
66
|
| Tool | Description |
|
|
98
67
|
|------|-------------|
|
|
99
68
|
| `attesso_pay` | Execute payment against mandate |
|
|
100
|
-
| `attesso_get_mandate` | Check spending
|
|
101
|
-
| `attesso_get_passport` | Get identity token |
|
|
69
|
+
| `attesso_get_mandate` | Check spending constraints |
|
|
70
|
+
| `attesso_get_passport` | Get identity token for merchant verification |
|
|
102
71
|
| `attesso_capture` | Capture authorized payment |
|
|
103
|
-
| `attesso_cancel` | Cancel and release funds |
|
|
72
|
+
| `attesso_cancel` | Cancel and release held funds |
|
|
104
73
|
| `attesso_check_balance` | Quick balance check |
|
|
105
74
|
|
|
106
75
|
### Configuration
|
|
@@ -109,7 +78,7 @@ const result = await generateText({
|
|
|
109
78
|
const tools = attesso.tools({
|
|
110
79
|
mandateId: 'mandate_xyz', // Pre-select mandate
|
|
111
80
|
merchant: 'United Airlines', // Lock to merchant
|
|
112
|
-
maxAmountPerTransaction: 50000, //
|
|
81
|
+
maxAmountPerTransaction: 50000, // Per-transaction cap
|
|
113
82
|
});
|
|
114
83
|
```
|
|
115
84
|
|
|
@@ -148,52 +117,15 @@ await client.cancel(auth.id);
|
|
|
148
117
|
const passport = await client.getPassport(mandateId);
|
|
149
118
|
```
|
|
150
119
|
|
|
151
|
-
##
|
|
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 |
|
|
120
|
+
## Security Model
|
|
190
121
|
|
|
191
|
-
|
|
192
|
-
-
|
|
193
|
-
-
|
|
194
|
-
-
|
|
122
|
+
- **FIDO2/WebAuthn**: Mandates signed by device Secure Enclave/TPM
|
|
123
|
+
- **Zero Card Exposure**: Agents receive mandate IDs, never card numbers
|
|
124
|
+
- **Hardware Attestation**: Non-exportable keys, origin-bound credentials
|
|
125
|
+
- **Spend Constraints**: Amount limits, merchant restrictions, TTL
|
|
126
|
+
- **Instant Revocation**: Immediate credential invalidation via API
|
|
195
127
|
|
|
196
|
-
### Hardware Security
|
|
128
|
+
### Hardware Security
|
|
197
129
|
|
|
198
130
|
| Device | Security | Auth Method |
|
|
199
131
|
|--------|----------|-------------|
|
|
@@ -201,21 +133,15 @@ Merchant verifies → Passport proves authorized spending
|
|
|
201
133
|
| Mac (Touch ID) | Secure Enclave | TouchID |
|
|
202
134
|
| Mac (no Touch ID) | Phone via QR | Phone's Secure Enclave |
|
|
203
135
|
| Windows (Hello) | TPM 2.0 | Windows Hello |
|
|
204
|
-
| Windows (no Hello) | Phone via QR | Requires Bluetooth + manual selection |
|
|
205
136
|
| Android | TEE/StrongBox | Fingerprint/Face |
|
|
206
137
|
|
|
207
|
-
|
|
138
|
+
## Application Fee Routing
|
|
208
139
|
|
|
209
|
-
|
|
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
|
|
140
|
+
Configure fees per transaction. Additive settlement model ensures merchant principal preservation:
|
|
214
141
|
|
|
215
142
|
```typescript
|
|
216
|
-
// Principal is $100, total authorization is $106
|
|
217
143
|
const payment = await rails.processPayment({
|
|
218
|
-
amount: 10000, // $100.00 principal
|
|
144
|
+
amount: 10000, // $100.00 principal
|
|
219
145
|
currency: 'usd',
|
|
220
146
|
merchant: 'Acme Corp',
|
|
221
147
|
mandateId: 'mandate_xyz',
|
|
@@ -223,44 +149,12 @@ const payment = await rails.processPayment({
|
|
|
223
149
|
userId: 'user_123',
|
|
224
150
|
applicationFee: {
|
|
225
151
|
destinationAccountId: 'acct_your_stripe_connect_id',
|
|
226
|
-
feePercent: 5,
|
|
227
|
-
// OR
|
|
228
|
-
feeFixed: 100, // fixed amount (cents)
|
|
229
|
-
// OR both combined
|
|
152
|
+
feePercent: 5,
|
|
230
153
|
},
|
|
231
154
|
});
|
|
232
155
|
```
|
|
233
156
|
|
|
234
|
-
|
|
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)
|
|
157
|
+
## Origin Restrictions
|
|
264
158
|
|
|
265
159
|
Restrict SDK usage to specific domains:
|
|
266
160
|
|
|
@@ -269,37 +163,32 @@ const client = new AttessoClient({
|
|
|
269
163
|
apiKey: 'sk_bot_xyz',
|
|
270
164
|
allowedOrigins: [
|
|
271
165
|
'https://myapp.com',
|
|
272
|
-
'https://*.trusted-partner.com',
|
|
166
|
+
'https://*.trusted-partner.com',
|
|
273
167
|
],
|
|
274
168
|
});
|
|
275
169
|
```
|
|
276
170
|
|
|
277
|
-
Requests from non-allowed origins throw `OriginNotAllowedError`.
|
|
278
|
-
|
|
279
171
|
## Environment Variables
|
|
280
172
|
|
|
281
173
|
```bash
|
|
282
174
|
ATTESSO_API_KEY=your_api_key
|
|
283
|
-
ATTESSO_BASE_URL=https://api.attesso.
|
|
175
|
+
ATTESSO_BASE_URL=https://api.attesso.com # optional
|
|
284
176
|
```
|
|
285
177
|
|
|
286
178
|
## TypeScript
|
|
287
179
|
|
|
288
|
-
Full type safety included:
|
|
289
|
-
|
|
290
180
|
```typescript
|
|
291
181
|
import type {
|
|
292
182
|
MandateResponse,
|
|
293
183
|
PaymentResponse,
|
|
294
184
|
PassportToken,
|
|
295
|
-
WebAuthnAssertion,
|
|
296
185
|
} from '@attesso/sdk';
|
|
297
186
|
```
|
|
298
187
|
|
|
299
188
|
## Requirements
|
|
300
189
|
|
|
301
190
|
- Node.js 18+
|
|
302
|
-
- For Vercel AI SDK
|
|
191
|
+
- For Vercel AI SDK: `ai` >= 3.0, `zod` >= 3.0
|
|
303
192
|
|
|
304
193
|
## License
|
|
305
194
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attesso/sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Financial infrastructure for AI agents. Scoped, ephemeral card credentials with FIDO2 authorization and hardware-bound spend constraints.",
|
|
5
5
|
"author": "Attesso",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -40,12 +40,13 @@
|
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"attesso",
|
|
43
|
-
"payments",
|
|
44
43
|
"ai-agents",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
44
|
+
"fido2",
|
|
45
|
+
"webauthn",
|
|
46
|
+
"card-issuing",
|
|
47
|
+
"ephemeral-credentials",
|
|
48
|
+
"financial-infrastructure",
|
|
49
|
+
"vercel-ai-sdk"
|
|
49
50
|
],
|
|
50
51
|
"dependencies": {
|
|
51
52
|
"@attesso/gatekeeper": "workspace:*",
|