vercel-ai-attesso 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 +182 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# vercel-ai-attesso
|
|
2
|
+
|
|
3
|
+
Vercel AI SDK provider for hardware-secured agent wallets. No app required.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install vercel-ai-attesso ai zod
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## One-Liner Integration
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { generateText } from 'ai';
|
|
13
|
+
import { attesso } from 'vercel-ai-attesso';
|
|
14
|
+
|
|
15
|
+
const result = await generateText({
|
|
16
|
+
model: openai('gpt-4o'),
|
|
17
|
+
tools: attesso.tools(),
|
|
18
|
+
prompt: 'Book me a flight to NYC under $500',
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
That's it. Your AI agent now has a wallet.
|
|
23
|
+
|
|
24
|
+
## What This Does
|
|
25
|
+
|
|
26
|
+
When you add `attesso.tools()` to your Vercel AI SDK agent, it gains these capabilities:
|
|
27
|
+
|
|
28
|
+
| Tool | Description |
|
|
29
|
+
|------|-------------|
|
|
30
|
+
| `attesso_pay` | Execute a payment against a user's pre-authorized mandate |
|
|
31
|
+
| `attesso_get_mandate` | Check spending limits and available funds |
|
|
32
|
+
| `attesso_get_passport` | Get identity token for merchant verification |
|
|
33
|
+
| `attesso_capture` | Capture a previously authorized payment |
|
|
34
|
+
| `attesso_cancel` | Cancel an auth and release funds |
|
|
35
|
+
| `attesso_check_balance` | Quick balance check |
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// Pre-configure mandate and merchant for tighter control
|
|
41
|
+
const tools = attesso.tools({
|
|
42
|
+
mandateId: 'mandate_xyz', // Pre-selected mandate
|
|
43
|
+
merchant: 'United Airlines', // Lock to single merchant
|
|
44
|
+
maxAmountPerTransaction: 50000, // $500 cap per transaction
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Environment Variables
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
ATTESSO_API_KEY=your_api_key_here
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## How It Works
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
58
|
+
│ Your AI Agent (Vercel AI SDK) │
|
|
59
|
+
│ ┌───────────────────────────────────────────────────────────┐ │
|
|
60
|
+
│ │ generateText({ │ │
|
|
61
|
+
│ │ model: openai('gpt-4o'), │ │
|
|
62
|
+
│ │ tools: attesso.tools(), ◄─── Hardware-secured wallet │ │
|
|
63
|
+
│ │ prompt: 'Book a flight...' │ │
|
|
64
|
+
│ │ }) │ │
|
|
65
|
+
│ └───────────────────────────────────────────────────────────┘ │
|
|
66
|
+
│ │ │
|
|
67
|
+
│ ▼ │
|
|
68
|
+
│ ┌───────────────────────────────────────────────────────────┐ │
|
|
69
|
+
│ │ Attesso API │ │
|
|
70
|
+
│ │ • Mandate validation (user pre-approved with passkey) │ │
|
|
71
|
+
│ │ • Hardware attestation (WebAuthn / Secure Enclave) │ │
|
|
72
|
+
│ │ • Payment execution via Stripe │ │
|
|
73
|
+
│ │ • Reputation & fraud monitoring │ │
|
|
74
|
+
│ └───────────────────────────────────────────────────────────┘ │
|
|
75
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## How Users Authorize Spending
|
|
79
|
+
|
|
80
|
+
Users create mandates in your web dashboard using WebAuthn passkeys:
|
|
81
|
+
|
|
82
|
+
1. User clicks "Create Mandate"
|
|
83
|
+
2. Browser prompts for passkey authentication:
|
|
84
|
+
- **Native**: FaceID/TouchID on Mac, iPhone, Android
|
|
85
|
+
- **Cross-device**: QR code scanned with phone (desktops without biometrics)
|
|
86
|
+
3. Device's Secure Enclave signs the mandate
|
|
87
|
+
4. Your agent receives the mandateId
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Frontend: Create mandate with passkey
|
|
91
|
+
const authOptions = await fetch('/api/auth/webauthn/authenticate/options', {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
}).then(r => r.json());
|
|
94
|
+
|
|
95
|
+
// User does FaceID/TouchID or scans QR with phone
|
|
96
|
+
const assertion = await navigator.credentials.get({
|
|
97
|
+
publicKey: authOptions,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const mandate = await fetch('/api/mandates', {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
body: JSON.stringify({
|
|
103
|
+
botId: 'bot_travel_agent',
|
|
104
|
+
maxAmount: 50000,
|
|
105
|
+
webAuthnAssertion: assertion,
|
|
106
|
+
}),
|
|
107
|
+
}).then(r => r.json());
|
|
108
|
+
|
|
109
|
+
// Pass mandateId to your AI agent
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Auth/Capture Flow
|
|
113
|
+
|
|
114
|
+
For purchases where the final price isn't known upfront:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const result = await generateText({
|
|
118
|
+
model: openai('gpt-4o'),
|
|
119
|
+
tools: attesso.tools({ mandateId }),
|
|
120
|
+
prompt: `
|
|
121
|
+
Search for flights to NYC.
|
|
122
|
+
When you find the best option, capture it with the exact price.
|
|
123
|
+
If nothing suitable, cancel the authorization.
|
|
124
|
+
`,
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The agent will:
|
|
129
|
+
1. Use `attesso_get_mandate` to check available funds
|
|
130
|
+
2. Search for flights (using your other tools)
|
|
131
|
+
3. Use `attesso_pay` to authorize the best price
|
|
132
|
+
4. Use `attesso_capture` or `attesso_cancel` based on results
|
|
133
|
+
|
|
134
|
+
## Passport Tokens
|
|
135
|
+
|
|
136
|
+
Get a cryptographic proof of spending power for merchant verification:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
const tools = attesso.tools();
|
|
140
|
+
// Agent calls attesso_get_passport to get JWT
|
|
141
|
+
// JWT contains: solvency proof, reputation score, mandate limits
|
|
142
|
+
// Merchant can verify locally without calling Attesso
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Why This Exists
|
|
146
|
+
|
|
147
|
+
AI agents need to spend money. Giving them your credit card is a bad idea.
|
|
148
|
+
|
|
149
|
+
Attesso provides:
|
|
150
|
+
- **WebAuthn passkeys** - Hardware-backed auth, no app required
|
|
151
|
+
- **Cross-device support** - QR code for desktops without biometrics
|
|
152
|
+
- **User-controlled limits** - Pre-authorized mandates with caps
|
|
153
|
+
- **Instant revocation** - Cancel any mandate immediately
|
|
154
|
+
- **Full audit trail** - Every transaction logged
|
|
155
|
+
|
|
156
|
+
## Hardware Security by Device
|
|
157
|
+
|
|
158
|
+
| Device | Security | Auth Method |
|
|
159
|
+
|--------|----------|-------------|
|
|
160
|
+
| iPhone/iPad | Secure Enclave | FaceID/TouchID |
|
|
161
|
+
| Mac (Touch ID) | Secure Enclave | TouchID |
|
|
162
|
+
| Mac (no Touch ID) | Phone via QR | Phone's Secure Enclave |
|
|
163
|
+
| Windows (Hello) | TPM 2.0 | Windows Hello |
|
|
164
|
+
| Windows (no Hello) | Phone via QR | Requires Bluetooth + manual selection |
|
|
165
|
+
| Android | TEE/StrongBox | Fingerprint/Face |
|
|
166
|
+
|
|
167
|
+
**Windows Note:** Without Windows Hello, users see USB security key prompt first. They must click Cancel and select "iPhone/Android" for QR code.
|
|
168
|
+
|
|
169
|
+
## Requirements
|
|
170
|
+
|
|
171
|
+
- Node.js 18+
|
|
172
|
+
- Vercel AI SDK 3.0+
|
|
173
|
+
- Zod 3.0+
|
|
174
|
+
|
|
175
|
+
## Links
|
|
176
|
+
|
|
177
|
+
- Website: https://attesso.com
|
|
178
|
+
- Support: info@attesso.com
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AttessoToolsConfig, attesso, attessoSchemas, createAttessoTools } from '@attesso/sdk/vercel';
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vercel-ai-attesso",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Vercel AI SDK provider for hardware-secured agent wallets",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
21
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"vercel",
|
|
26
|
+
"ai-sdk",
|
|
27
|
+
"openai",
|
|
28
|
+
"agents",
|
|
29
|
+
"payments",
|
|
30
|
+
"wallets",
|
|
31
|
+
"attesso",
|
|
32
|
+
"ai",
|
|
33
|
+
"tools"
|
|
34
|
+
],
|
|
35
|
+
"author": "Attesso",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/attesso/vercel-ai-attesso.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/attesso/vercel-ai-attesso#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/attesso/vercel-ai-attesso/issues"
|
|
44
|
+
},
|
|
45
|
+
"deprecated": "Use @attesso/sdk/vercel instead. This package is now a re-export.",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@attesso/sdk": "^1.0.2"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"ai": ">=3.0.0",
|
|
51
|
+
"zod": ">=3.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"ai": "^3.0.0",
|
|
55
|
+
"tsup": "^8.0.0",
|
|
56
|
+
"typescript": "^5.3.0",
|
|
57
|
+
"zod": "^3.22.0"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=18.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|