spaps 0.3.9 → 0.3.10

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 CHANGED
@@ -1,82 +1,209 @@
1
- # spaps
1
+ # 🍠 SPAPS CLI
2
2
 
3
- > Sweet Potato Authentication & Payment Service CLI
3
+ > **Sweet Potato Authentication & Payment Service CLI**
4
+ > Zero-config local development server with real Stripe integration
4
5
 
5
- Zero-config local development for SPAPS authentication and payments.
6
+ [![npm version](https://badge.fury.io/js/spaps.svg)](https://badge.fury.io/js/spaps)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
8
 
7
- ## Quick Start
9
+ ## 🚀 Quick Start
8
10
 
9
11
  ```bash
12
+ # Run immediately with npx (recommended)
10
13
  npx spaps local
14
+
15
+ # Or install globally
16
+ npm install -g spaps
17
+ spaps local
11
18
  ```
12
19
 
13
- That's it! Your local SPAPS server is running at http://localhost:3300 🚀
20
+ **That's it!** Your local SPAPS server is now running at http://localhost:3456 🎉
14
21
 
15
- **New in v0.2.0**: The `spaps local` command now starts a real server!
22
+ ## What is SPAPS?
16
23
 
17
- ## Installation
24
+ SPAPS provides a **complete authentication and payment backend** for your applications:
18
25
 
19
- ```bash
20
- npm install -g spaps
21
- # or
22
- yarn global add spaps
23
- ```
26
+ - 🔐 **Multi-wallet auth** (Solana, Ethereum, Bitcoin, Base)
27
+ - 📧 **Traditional auth** (email/password, magic links)
28
+ - 💳 **Real Stripe integration** (products, checkout, webhooks)
29
+ - 🎭 **Test user switching** (`?_user=admin`)
30
+ - 📊 **Admin dashboard** with analytics
31
+ - 🌐 **CORS-ready** for any frontend
24
32
 
25
- ## Commands
33
+ Perfect for **rapid prototyping**, **hackathons**, and **local development**.
26
34
 
27
- ### `spaps local`
28
- Start a local SPAPS development server with:
29
- - No API keys required
30
- - Auto-authentication enabled
31
- - Test users (user/admin/premium)
32
- - CORS configured for any frontend
33
- - Mock Stripe endpoints
34
- - Full auth flow support
35
+ ## 📋 Commands
35
36
 
36
- ```bash
37
- spaps local
38
- # Server running at http://localhost:3300
39
- # Documentation at http://localhost:3300/docs
37
+ ### `spaps local` - Development Server
38
+
39
+ Start a full-featured local server with zero configuration:
40
40
 
41
- # Options:
42
- spaps local --port 3301 # Use different port
43
- spaps local --open # Open browser automatically
41
+ ```bash
42
+ spaps local # Default: http://localhost:3456
43
+ spaps local --port 3000 # Custom port
44
+ spaps local --json # JSON output (CI-friendly)
44
45
  ```
45
46
 
46
- ### `spaps init`
47
+ **Includes:**
48
+ - ✅ Auto-authentication (no API keys needed)
49
+ - ✅ Real Stripe test mode integration
50
+ - ✅ Mock payment flows with webhooks
51
+ - ✅ Admin dashboard at `/admin`
52
+ - ✅ API documentation at `/docs`
53
+ - ✅ Test user switching via headers/query params
54
+
55
+ ### `spaps init` - Project Setup
56
+
47
57
  Initialize SPAPS in an existing project:
58
+
48
59
  ```bash
49
60
  spaps init
50
- # Creates .env.local with minimal config
51
- # Adds SPAPS SDK to package.json
61
+ # Creates .env.local with Stripe test keys
62
+ # Adds SPAPS client to your package.json
63
+ # ✅ Generates basic integration examples
52
64
  ```
53
65
 
54
- ### `spaps create <name>` (Coming Soon)
55
- Create a new project with SPAPS pre-configured:
66
+ ### `spaps status` - Health Check
67
+
68
+ Check your local server and Stripe connection:
69
+
56
70
  ```bash
57
- spaps create my-app
58
- # Choose framework: Next.js, React, Node.js
59
- # Includes authentication examples
71
+ spaps status
72
+ # Shows server status, Stripe connectivity, product sync status
60
73
  ```
61
74
 
62
- ### `spaps types` (Coming Soon)
63
- Generate TypeScript types from your SPAPS setup:
75
+ ## 🎯 Key Features
76
+
77
+ ### 🔧 **Zero Configuration**
78
+ - No setup required - works out of the box
79
+ - Real Stripe test keys included
80
+ - Automatic CORS for any frontend
81
+
82
+ ### 🎭 **Smart Test Users**
83
+ Switch between user roles instantly:
84
+
64
85
  ```bash
65
- spaps types > types/spaps.d.ts
86
+ # Via query parameter
87
+ curl "http://localhost:3456/api/auth/user?_user=admin"
88
+
89
+ # Via header
90
+ curl -H "X-Test-User: premium" "http://localhost:3456/api/auth/user"
91
+ ```
92
+
93
+ Available roles: `user`, `admin`, `premium`
94
+
95
+ ### 💳 **Real Stripe Integration**
96
+ - **Real API calls** to Stripe test mode
97
+ - Create actual checkout sessions
98
+ - Receive real webhooks
99
+ - Sync products to/from Stripe
100
+ - Full webhook testing UI at `/api/stripe/webhooks/test`
101
+
102
+ ### 📊 **Admin Dashboard**
103
+ Visit `/admin` for a complete management interface:
104
+ - Revenue analytics
105
+ - Product management
106
+ - Order tracking
107
+ - Data export/import
108
+ - Real-time webhook monitoring
109
+
110
+ ## 🔌 API Endpoints
111
+
112
+ | Endpoint | Method | Description |
113
+ |----------|--------|-------------|
114
+ | `/api/auth/login` | POST | Email/password authentication |
115
+ | `/api/auth/wallet-sign-in` | POST | Wallet signature authentication |
116
+ | `/api/auth/magic-link` | POST | Send magic link email |
117
+ | `/api/stripe/products` | GET | List Stripe products |
118
+ | `/api/stripe/checkout-sessions` | POST | Create checkout session |
119
+ | `/api/stripe/webhooks` | POST | Handle Stripe webhooks |
120
+ | `/api/admin/products` | GET/POST | Manage products |
121
+ | `/health` | GET | Server health check |
122
+ | `/docs` | GET | Interactive API documentation |
123
+
124
+ ## 💡 Usage Examples
125
+
126
+ ### Frontend Integration
127
+
128
+ ```javascript
129
+ // React/Next.js example
130
+ const createCheckout = async () => {
131
+ const response = await fetch('http://localhost:3456/api/stripe/checkout-sessions', {
132
+ method: 'POST',
133
+ headers: { 'Content-Type': 'application/json' },
134
+ body: JSON.stringify({
135
+ price_id: 'price_1234567890',
136
+ success_url: 'http://localhost:3000/success',
137
+ cancel_url: 'http://localhost:3000/cancel'
138
+ })
139
+ });
140
+
141
+ const { data } = await response.json();
142
+ window.location.href = data.url; // Redirect to Stripe Checkout
143
+ };
66
144
  ```
67
145
 
68
- ## Local Mode Features
146
+ ### Test Different User Roles
147
+
148
+ ```javascript
149
+ // Test as admin user
150
+ fetch('http://localhost:3456/api/auth/user?_user=admin')
151
+
152
+ // Test wallet authentication
153
+ fetch('http://localhost:3456/api/auth/wallet-sign-in', {
154
+ method: 'POST',
155
+ body: JSON.stringify({
156
+ wallet_address: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa',
157
+ chain_type: 'bitcoin'
158
+ })
159
+ });
160
+ ```
161
+
162
+ ## 🏗️ Development Workflow
163
+
164
+ 1. **Start SPAPS**: `npx spaps local`
165
+ 2. **Build your frontend** against `http://localhost:3456`
166
+ 3. **Test payments** using Stripe's test cards
167
+ 4. **Monitor webhooks** at `/api/stripe/webhooks/test`
168
+ 5. **Manage data** via `/admin` dashboard
169
+ 6. **Export data** when ready for production
170
+
171
+ ## 🔒 Environment & Security
69
172
 
70
- - **Zero Configuration**: Just run and go
71
- - **Auto Authentication**: No API keys needed
72
- - **Test Users**: Switch between user/admin/premium
73
- - **CORS Enabled**: Works with any frontend
74
- - **Production Safe**: Can't accidentally run in production
173
+ **Local Mode Safety:**
174
+ - Only runs on localhost (production-safe)
175
+ - Uses Stripe test keys by default
176
+ - All data stored locally in `.spaps/` directory
177
+ - Headers indicate local development mode
178
+
179
+ **Stripe Configuration:**
180
+ - Real Stripe test API integration
181
+ - Webhook signature verification
182
+ - Product/price synchronization
183
+ - Customer portal simulation
184
+
185
+ ## 📦 Installation Options
186
+
187
+ ```bash
188
+ # Use immediately (recommended)
189
+ npx spaps local
190
+
191
+ # Install globally
192
+ npm install -g spaps
193
+
194
+ # Add to project dependencies
195
+ npm install --save-dev spaps
196
+ ```
75
197
 
76
- ## Documentation
198
+ ## 🎓 Next Steps
77
199
 
78
- Full documentation at [sweetpotato.dev](https://sweetpotato.dev)
200
+ - 📖 **Full Documentation**: [sweetpotato.dev](https://sweetpotato.dev)
201
+ - 🔧 **Production Setup**: See deployment guides
202
+ - 💬 **Get Help**: [GitHub Issues](https://github.com/yourusername/sweet-potato/issues)
203
+ - 🚀 **Examples**: Check `/examples` directory
79
204
 
80
- ## License
205
+ ---
81
206
 
82
- MIT
207
+ **Current Version**: v0.3.9
208
+ **License**: MIT
209
+ **Node.js**: >=16.0.0 required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spaps",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "description": "Sweet Potato Authentication & Payment Service CLI - Zero-config local development and project scaffolding",
5
5
  "main": "bin/spaps.js",
6
6
  "bin": {
@@ -95,12 +95,15 @@ class LocalServer {
95
95
  this.app.post('/api/auth/login', (req, res) => {
96
96
  const { email, password } = req.body;
97
97
  res.json({
98
- access_token: 'local-jwt-token-' + Date.now(),
99
- refresh_token: 'local-refresh-token-' + Date.now(),
100
- user: {
101
- id: 'local-user-123',
102
- email: email || 'dev@localhost',
103
- role: 'user'
98
+ success: true,
99
+ data: {
100
+ access_token: 'local-jwt-token-' + Date.now(),
101
+ refresh_token: 'local-refresh-token-' + Date.now(),
102
+ user: {
103
+ id: 'local-user-123',
104
+ email: email || 'dev@localhost',
105
+ role: 'user'
106
+ }
104
107
  }
105
108
  });
106
109
  });
@@ -108,12 +111,15 @@ class LocalServer {
108
111
  this.app.post('/api/auth/register', (req, res) => {
109
112
  const { email, password } = req.body;
110
113
  res.json({
111
- access_token: 'local-jwt-token-' + Date.now(),
112
- refresh_token: 'local-refresh-token-' + Date.now(),
113
- user: {
114
- id: 'local-user-' + Date.now(),
115
- email: email || 'dev@localhost',
116
- role: 'user'
114
+ success: true,
115
+ data: {
116
+ access_token: 'local-jwt-token-' + Date.now(),
117
+ refresh_token: 'local-refresh-token-' + Date.now(),
118
+ user: {
119
+ id: 'local-user-' + Date.now(),
120
+ email: email || 'dev@localhost',
121
+ role: 'user'
122
+ }
117
123
  }
118
124
  });
119
125
  });
@@ -121,21 +127,27 @@ class LocalServer {
121
127
  this.app.post('/api/auth/wallet-sign-in', (req, res) => {
122
128
  const { wallet_address, chain_type } = req.body;
123
129
  res.json({
124
- access_token: 'local-jwt-token-' + Date.now(),
125
- refresh_token: 'local-refresh-token-' + Date.now(),
126
- user: {
127
- id: 'local-wallet-user-123',
128
- wallet_address,
129
- chain_type,
130
- role: 'user'
130
+ success: true,
131
+ data: {
132
+ access_token: 'local-jwt-token-' + Date.now(),
133
+ refresh_token: 'local-refresh-token-' + Date.now(),
134
+ user: {
135
+ id: 'local-wallet-user-123',
136
+ wallet_address,
137
+ chain_type,
138
+ role: 'user'
139
+ }
131
140
  }
132
141
  });
133
142
  });
134
143
 
135
144
  this.app.post('/api/auth/refresh', (req, res) => {
136
145
  res.json({
137
- access_token: 'local-jwt-token-refreshed-' + Date.now(),
138
- refresh_token: 'local-refresh-token-refreshed-' + Date.now()
146
+ success: true,
147
+ data: {
148
+ access_token: 'local-jwt-token-refreshed-' + Date.now(),
149
+ refresh_token: 'local-refresh-token-refreshed-' + Date.now()
150
+ }
139
151
  });
140
152
  });
141
153