@intentsolutionsio/vercel-pack 1.0.0 → 1.0.3
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 +1 -1
- package/README.md +67 -44
- package/package.json +4 -4
- package/skills/vercel-advanced-troubleshooting/SKILL.md +185 -195
- package/skills/vercel-advanced-troubleshooting/references/errors.md +11 -0
- package/skills/vercel-advanced-troubleshooting/references/evidence-collection-framework.md +34 -0
- package/skills/vercel-advanced-troubleshooting/references/examples.md +11 -0
- package/skills/vercel-advanced-troubleshooting/references/systematic-isolation.md +56 -0
- package/skills/vercel-advanced-troubleshooting/references/timing-analysis.md +35 -0
- package/skills/vercel-architecture-variants/SKILL.md +227 -216
- package/skills/vercel-architecture-variants/references/errors.md +11 -0
- package/skills/vercel-architecture-variants/references/examples.md +12 -0
- package/skills/vercel-architecture-variants/references/variant-a-monolith-(simple).md +44 -0
- package/skills/vercel-architecture-variants/references/variant-b-service-layer-(moderate).md +72 -0
- package/skills/vercel-architecture-variants/references/variant-c-microservice-(complex).md +81 -0
- package/skills/vercel-ci-integration/SKILL.md +183 -73
- package/skills/vercel-ci-integration/references/errors.md +10 -0
- package/skills/vercel-ci-integration/references/examples.md +36 -0
- package/skills/vercel-ci-integration/references/implementation.md +54 -0
- package/skills/vercel-common-errors/SKILL.md +164 -60
- package/skills/vercel-common-errors/references/errors.md +53 -0
- package/skills/vercel-common-errors/references/examples.md +23 -0
- package/skills/vercel-cost-tuning/SKILL.md +158 -145
- package/skills/vercel-cost-tuning/references/cost-estimation.md +34 -0
- package/skills/vercel-cost-tuning/references/cost-reduction-strategies.md +40 -0
- package/skills/vercel-cost-tuning/references/errors.md +11 -0
- package/skills/vercel-cost-tuning/references/examples.md +15 -0
- package/skills/vercel-data-handling/SKILL.md +202 -155
- package/skills/vercel-data-handling/references/errors.md +11 -0
- package/skills/vercel-data-handling/references/examples.md +27 -0
- package/skills/vercel-data-handling/references/implementation.md +223 -0
- package/skills/vercel-debug-bundle/SKILL.md +163 -67
- package/skills/vercel-debug-bundle/references/errors.md +12 -0
- package/skills/vercel-debug-bundle/references/examples.md +24 -0
- package/skills/vercel-debug-bundle/references/implementation.md +54 -0
- package/skills/vercel-deploy-integration/SKILL.md +163 -156
- package/skills/vercel-deploy-integration/references/errors.md +11 -0
- package/skills/vercel-deploy-integration/references/examples.md +21 -0
- package/skills/vercel-deploy-integration/references/google-cloud-run.md +36 -0
- package/skills/vercel-deploy-integration/references/vercel-deployment.md +35 -0
- package/skills/vercel-deploy-preview/SKILL.md +164 -39
- package/skills/vercel-edge-functions/SKILL.md +185 -37
- package/skills/vercel-enterprise-rbac/SKILL.md +185 -170
- package/skills/vercel-enterprise-rbac/references/errors.md +11 -0
- package/skills/vercel-enterprise-rbac/references/examples.md +12 -0
- package/skills/vercel-enterprise-rbac/references/role-implementation.md +33 -0
- package/skills/vercel-enterprise-rbac/references/sso-integration.md +35 -0
- package/skills/vercel-hello-world/SKILL.md +141 -55
- package/skills/vercel-incident-runbook/SKILL.md +186 -138
- package/skills/vercel-incident-runbook/references/errors.md +11 -0
- package/skills/vercel-incident-runbook/references/examples.md +10 -0
- package/skills/vercel-incident-runbook/references/immediate-actions-by-error-type.md +41 -0
- package/skills/vercel-install-auth/SKILL.md +130 -53
- package/skills/vercel-known-pitfalls/SKILL.md +235 -233
- package/skills/vercel-known-pitfalls/references/errors.md +11 -0
- package/skills/vercel-known-pitfalls/references/examples.md +12 -0
- package/skills/vercel-load-scale/SKILL.md +197 -204
- package/skills/vercel-load-scale/references/capacity-planning.md +47 -0
- package/skills/vercel-load-scale/references/errors.md +11 -0
- package/skills/vercel-load-scale/references/examples.md +26 -0
- package/skills/vercel-load-scale/references/load-testing-with-k6.md +59 -0
- package/skills/vercel-load-scale/references/scaling-patterns.md +65 -0
- package/skills/vercel-local-dev-loop/SKILL.md +159 -71
- package/skills/vercel-local-dev-loop/references/errors.md +11 -0
- package/skills/vercel-local-dev-loop/references/examples.md +21 -0
- package/skills/vercel-local-dev-loop/references/implementation.md +60 -0
- package/skills/vercel-migration-deep-dive/SKILL.md +202 -187
- package/skills/vercel-migration-deep-dive/references/errors.md +11 -0
- package/skills/vercel-migration-deep-dive/references/examples.md +12 -0
- package/skills/vercel-migration-deep-dive/references/implementation-plan.md +80 -0
- package/skills/vercel-migration-deep-dive/references/pre-migration-assessment.md +39 -0
- package/skills/vercel-multi-env-setup/SKILL.md +167 -164
- package/skills/vercel-multi-env-setup/references/configuration-structure.md +59 -0
- package/skills/vercel-multi-env-setup/references/errors.md +11 -0
- package/skills/vercel-multi-env-setup/references/examples.md +11 -0
- package/skills/vercel-observability/SKILL.md +205 -195
- package/skills/vercel-observability/references/alert-configuration.md +40 -0
- package/skills/vercel-observability/references/errors.md +11 -0
- package/skills/vercel-observability/references/examples.md +13 -0
- package/skills/vercel-observability/references/metrics-collection.md +65 -0
- package/skills/vercel-performance-tuning/SKILL.md +212 -156
- package/skills/vercel-performance-tuning/references/caching-strategy.md +49 -0
- package/skills/vercel-performance-tuning/references/errors.md +11 -0
- package/skills/vercel-performance-tuning/references/examples.md +13 -0
- package/skills/vercel-policy-guardrails/SKILL.md +276 -193
- package/skills/vercel-policy-guardrails/references/errors.md +11 -0
- package/skills/vercel-policy-guardrails/references/eslint-rules.md +46 -0
- package/skills/vercel-policy-guardrails/references/examples.md +10 -0
- package/skills/vercel-prod-checklist/SKILL.md +219 -94
- package/skills/vercel-prod-checklist/references/errors.md +11 -0
- package/skills/vercel-prod-checklist/references/examples.md +25 -0
- package/skills/vercel-prod-checklist/references/implementation.md +60 -0
- package/skills/vercel-rate-limits/SKILL.md +187 -100
- package/skills/vercel-rate-limits/references/errors.md +11 -0
- package/skills/vercel-rate-limits/references/examples.md +46 -0
- package/skills/vercel-rate-limits/references/implementation.md +66 -0
- package/skills/vercel-reference-architecture/SKILL.md +226 -180
- package/skills/vercel-reference-architecture/references/errors.md +11 -0
- package/skills/vercel-reference-architecture/references/examples.md +13 -0
- package/skills/vercel-reference-architecture/references/key-components.md +65 -0
- package/skills/vercel-reference-architecture/references/project-structure.md +40 -0
- package/skills/vercel-reliability-patterns/SKILL.md +272 -211
- package/skills/vercel-reliability-patterns/references/circuit-breaker.md +36 -0
- package/skills/vercel-reliability-patterns/references/dead-letter-queue.md +48 -0
- package/skills/vercel-reliability-patterns/references/errors.md +11 -0
- package/skills/vercel-reliability-patterns/references/examples.md +11 -0
- package/skills/vercel-reliability-patterns/references/idempotency-keys.md +36 -0
- package/skills/vercel-sdk-patterns/SKILL.md +264 -92
- package/skills/vercel-sdk-patterns/references/errors.md +11 -0
- package/skills/vercel-sdk-patterns/references/examples.md +45 -0
- package/skills/vercel-sdk-patterns/references/implementation.md +67 -0
- package/skills/vercel-security-basics/SKILL.md +186 -96
- package/skills/vercel-security-basics/references/errors.md +10 -0
- package/skills/vercel-security-basics/references/examples.md +70 -0
- package/skills/vercel-security-basics/references/implementation.md +39 -0
- package/skills/vercel-upgrade-migration/SKILL.md +167 -67
- package/skills/vercel-upgrade-migration/references/errors.md +10 -0
- package/skills/vercel-upgrade-migration/references/examples.md +51 -0
- package/skills/vercel-upgrade-migration/references/implementation.md +29 -0
- package/skills/vercel-webhooks-events/SKILL.md +208 -132
- package/skills/vercel-webhooks-events/references/errors.md +11 -0
- package/skills/vercel-webhooks-events/references/event-handler-pattern.md +37 -0
- package/skills/vercel-webhooks-events/references/examples.md +16 -0
- package/skills/vercel-webhooks-events/references/signature-verification.md +33 -0
|
@@ -1,140 +1,230 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: vercel-security-basics
|
|
3
|
-
description:
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
description: 'Apply Vercel security best practices for secrets, headers, and access
|
|
4
|
+
control.
|
|
5
|
+
|
|
6
|
+
Use when securing API keys, configuring security headers,
|
|
7
|
+
|
|
6
8
|
or auditing Vercel security configuration.
|
|
9
|
+
|
|
7
10
|
Trigger with phrases like "vercel security", "vercel secrets",
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
"secure vercel", "vercel headers", "vercel CSP".
|
|
13
|
+
|
|
14
|
+
'
|
|
15
|
+
allowed-tools: Read, Write, Edit, Bash(vercel:*), Grep
|
|
10
16
|
version: 1.0.0
|
|
11
17
|
license: MIT
|
|
12
18
|
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
19
|
+
tags:
|
|
20
|
+
- saas
|
|
21
|
+
- vercel
|
|
22
|
+
- security
|
|
23
|
+
- headers
|
|
24
|
+
- secrets
|
|
25
|
+
compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw
|
|
13
26
|
---
|
|
14
|
-
|
|
15
27
|
# Vercel Security Basics
|
|
16
28
|
|
|
17
29
|
## Overview
|
|
18
|
-
|
|
30
|
+
|
|
31
|
+
Secure Vercel deployments with proper secret management, security headers, deployment protection, and access token hygiene. Covers environment variable scoping, Content Security Policy, and preventing common secret exposure patterns.
|
|
19
32
|
|
|
20
33
|
## Prerequisites
|
|
21
|
-
|
|
22
|
-
-
|
|
34
|
+
|
|
35
|
+
- Vercel CLI installed and authenticated
|
|
23
36
|
- Access to Vercel dashboard
|
|
37
|
+
- Understanding of HTTP security headers
|
|
24
38
|
|
|
25
39
|
## Instructions
|
|
26
40
|
|
|
27
|
-
### Step 1:
|
|
41
|
+
### Step 1: Secret Management with Environment Variables
|
|
42
|
+
|
|
28
43
|
```bash
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
# Add secrets scoped to specific environments
|
|
45
|
+
vercel env add DATABASE_URL production
|
|
46
|
+
vercel env add DATABASE_URL preview
|
|
47
|
+
vercel env add DATABASE_URL development
|
|
48
|
+
|
|
49
|
+
# Use 'sensitive' type — values hidden in dashboard and logs
|
|
50
|
+
vercel env add API_SECRET production --sensitive
|
|
51
|
+
|
|
52
|
+
# Via REST API
|
|
53
|
+
curl -X POST "https://api.vercel.com/v9/projects/my-app/env" \
|
|
54
|
+
-H "Authorization: Bearer $VERCEL_TOKEN" \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{
|
|
57
|
+
"key": "API_SECRET",
|
|
58
|
+
"value": "sk-secret-value",
|
|
59
|
+
"type": "sensitive",
|
|
60
|
+
"target": ["production"]
|
|
61
|
+
}'
|
|
37
62
|
```
|
|
38
63
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
**Critical rule:** Never prefix secrets with `NEXT_PUBLIC_`. Variables starting with `NEXT_PUBLIC_` are inlined into the client JavaScript bundle and visible to anyone.
|
|
65
|
+
|
|
66
|
+
### Step 2: Security Headers via vercel.json
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"headers": [
|
|
71
|
+
{
|
|
72
|
+
"source": "/(.*)",
|
|
73
|
+
"headers": [
|
|
74
|
+
{ "key": "X-Content-Type-Options", "value": "nosniff" },
|
|
75
|
+
{ "key": "X-Frame-Options", "value": "DENY" },
|
|
76
|
+
{ "key": "X-XSS-Protection", "value": "1; mode=block" },
|
|
77
|
+
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
|
|
78
|
+
{ "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" },
|
|
79
|
+
{
|
|
80
|
+
"key": "Strict-Transport-Security",
|
|
81
|
+
"value": "max-age=63072000; includeSubDomains; preload"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"key": "Content-Security-Policy",
|
|
85
|
+
"value": "default-src 'self'; script-src 'self' 'unsafe-inline' https://vercel.live; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://api.vercel.com"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
```
|
|
44
92
|
|
|
45
|
-
|
|
46
|
-
curl -H "Authorization: Bearer ${VERCEL_API_KEY}" \
|
|
47
|
-
https://api.vercel.com/health
|
|
93
|
+
### Step 3: Security Headers via Edge Middleware
|
|
48
94
|
|
|
49
|
-
|
|
95
|
+
```typescript
|
|
96
|
+
// middleware.ts
|
|
97
|
+
import { NextResponse } from 'next/server';
|
|
98
|
+
import type { NextRequest } from 'next/server';
|
|
99
|
+
|
|
100
|
+
export function middleware(request: NextRequest) {
|
|
101
|
+
const response = NextResponse.next();
|
|
102
|
+
|
|
103
|
+
// Security headers
|
|
104
|
+
response.headers.set('X-Content-Type-Options', 'nosniff');
|
|
105
|
+
response.headers.set('X-Frame-Options', 'DENY');
|
|
106
|
+
response.headers.set('Referrer-Policy', 'strict-origin-when-cross-origin');
|
|
107
|
+
response.headers.set(
|
|
108
|
+
'Strict-Transport-Security',
|
|
109
|
+
'max-age=63072000; includeSubDomains; preload'
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Remove server version headers
|
|
113
|
+
response.headers.delete('X-Powered-By');
|
|
114
|
+
|
|
115
|
+
return response;
|
|
116
|
+
}
|
|
50
117
|
```
|
|
51
118
|
|
|
52
|
-
### Step
|
|
53
|
-
| Environment | Recommended Scopes |
|
|
54
|
-
|-------------|-------------------|
|
|
55
|
-
| Development | `read, deploy` |
|
|
56
|
-
| Staging | `read, write, deploy` |
|
|
57
|
-
| Production | `read, write, deploy, domains` |
|
|
119
|
+
### Step 4: Deployment Protection
|
|
58
120
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
121
|
+
```json
|
|
122
|
+
// vercel.json
|
|
123
|
+
{
|
|
124
|
+
"deploymentProtection": {
|
|
125
|
+
"preview": "vercel-authentication",
|
|
126
|
+
"optedOutFrom": []
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
63
130
|
|
|
64
|
-
|
|
65
|
-
| Security Issue | Detection | Mitigation |
|
|
66
|
-
|----------------|-----------|------------|
|
|
67
|
-
| Exposed API key | Git scanning | Rotate immediately |
|
|
68
|
-
| Excessive scopes | Audit logs | Reduce permissions |
|
|
69
|
-
| Missing rotation | Key age check | Schedule rotation |
|
|
131
|
+
Protection options:
|
|
70
132
|
|
|
71
|
-
|
|
133
|
+
- **`vercel-authentication`** — requires Vercel team login to view preview deploys
|
|
134
|
+
- **`standard-protection`** — uses bypass header for automation
|
|
135
|
+
- **Deployment Protection Bypass** — for CI/CD and health checks:
|
|
72
136
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
writer: new VercelClient({
|
|
80
|
-
apiKey: process.env.VERCEL_WRITE_KEY,
|
|
81
|
-
}),
|
|
82
|
-
};
|
|
137
|
+
```bash
|
|
138
|
+
# Generate a bypass secret in Vercel dashboard > Settings > Deployment Protection
|
|
139
|
+
# Use in CI with:
|
|
140
|
+
curl -H "x-vercel-protection-bypass: your-bypass-secret" \
|
|
141
|
+
https://my-app-preview.vercel.app/api/health
|
|
83
142
|
```
|
|
84
143
|
|
|
85
|
-
###
|
|
86
|
-
```typescript
|
|
87
|
-
import crypto from 'crypto';
|
|
144
|
+
### Step 5: Access Token Best Practices
|
|
88
145
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
146
|
+
```bash
|
|
147
|
+
# Create scoped tokens — restrict to one team and project
|
|
148
|
+
# Settings > Tokens > Create Token:
|
|
149
|
+
# - Scope: Team → your-team
|
|
150
|
+
# - Expiration: 90 days (for CI)
|
|
151
|
+
# - Permissions: Deployment-only (no team admin)
|
|
152
|
+
|
|
153
|
+
# Rotate tokens on a schedule
|
|
154
|
+
# In CI (GitHub Actions):
|
|
155
|
+
# Store as GitHub Secret: VERCEL_TOKEN
|
|
156
|
+
# Set expiry alerts in your calendar
|
|
95
157
|
```
|
|
96
158
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
159
|
+
Token security rules:
|
|
160
|
+
|
|
161
|
+
1. Never commit tokens to git — use `.env.local` or CI secrets
|
|
162
|
+
2. Scope tokens to the minimum required permissions
|
|
163
|
+
3. Set expiration dates (90 days for CI, 30 days for dev)
|
|
164
|
+
4. Rotate immediately if exposed
|
|
165
|
+
5. Use separate tokens per environment/pipeline
|
|
166
|
+
|
|
167
|
+
### Step 6: API Route Authentication
|
|
104
168
|
|
|
105
|
-
### Audit Logging
|
|
106
169
|
```typescript
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
170
|
+
// api/protected.ts
|
|
171
|
+
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
|
172
|
+
|
|
173
|
+
export default function handler(req: VercelRequest, res: VercelResponse) {
|
|
174
|
+
// Verify API key from header
|
|
175
|
+
const apiKey = req.headers['x-api-key'];
|
|
176
|
+
if (!apiKey || apiKey !== process.env.INTERNAL_API_KEY) {
|
|
177
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Verify origin for CORS
|
|
181
|
+
const origin = req.headers.origin;
|
|
182
|
+
const allowedOrigins = (process.env.ALLOWED_ORIGINS ?? '').split(',');
|
|
183
|
+
if (origin && !allowedOrigins.includes(origin)) {
|
|
184
|
+
return res.status(403).json({ error: 'Forbidden origin' });
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
res.json({ data: 'protected content' });
|
|
114
188
|
}
|
|
189
|
+
```
|
|
115
190
|
|
|
116
|
-
|
|
117
|
-
const log: AuditEntry = { ...entry, timestamp: new Date() };
|
|
191
|
+
## Security Checklist
|
|
118
192
|
|
|
119
|
-
|
|
120
|
-
|
|
193
|
+
| Check | Status |
|
|
194
|
+
|-------|--------|
|
|
195
|
+
| No secrets in `NEXT_PUBLIC_*` variables | Required |
|
|
196
|
+
| Sensitive env vars use `type: sensitive` | Required |
|
|
197
|
+
| Security headers configured | Required |
|
|
198
|
+
| HSTS enabled with preload | Recommended |
|
|
199
|
+
| Preview deployments protected | Recommended |
|
|
200
|
+
| Access tokens scoped and rotated | Required |
|
|
201
|
+
| CSP configured for your domains | Recommended |
|
|
202
|
+
| `.env.local` in `.gitignore` | Required |
|
|
121
203
|
|
|
122
|
-
|
|
123
|
-
console.log('[AUDIT]', JSON.stringify(log));
|
|
124
|
-
}
|
|
204
|
+
## Output
|
|
125
205
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
206
|
+
- Environment variables properly scoped and typed as sensitive
|
|
207
|
+
- Security headers applied to all responses
|
|
208
|
+
- Deployment protection enabled for preview URLs
|
|
209
|
+
- Access tokens scoped with expiration dates
|
|
210
|
+
|
|
211
|
+
## Error Handling
|
|
212
|
+
|
|
213
|
+
| Error | Cause | Solution |
|
|
214
|
+
|-------|-------|----------|
|
|
215
|
+
| Secret visible in client bundle | Prefixed with `NEXT_PUBLIC_` | Remove prefix, redeploy, rotate the secret |
|
|
216
|
+
| CSP blocking resources | Policy too restrictive | Add the blocked domain to the relevant directive |
|
|
217
|
+
| Preview accessible without auth | Deployment protection disabled | Enable in vercel.json or dashboard |
|
|
218
|
+
| Token expired | Past expiration date | Generate new token, update CI secrets |
|
|
134
219
|
|
|
135
220
|
## Resources
|
|
136
|
-
|
|
137
|
-
- [Vercel
|
|
221
|
+
|
|
222
|
+
- [Vercel Security](https://vercel.com/docs/security)
|
|
223
|
+
- [Deployment Protection](https://vercel.com/docs/security/deployment-protection)
|
|
224
|
+
- [Environment Variables](https://vercel.com/docs/environment-variables)
|
|
225
|
+
- [Security Headers](https://vercel.com/docs/headers)
|
|
226
|
+
- [Access Tokens](https://vercel.com/docs/rest-api#creating-an-access-token)
|
|
138
227
|
|
|
139
228
|
## Next Steps
|
|
140
|
-
|
|
229
|
+
|
|
230
|
+
For production deployment checklist, see `vercel-prod-checklist`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Error Handling Reference
|
|
2
|
+
|
|
3
|
+
| Security Issue | Detection | Mitigation |
|
|
4
|
+
|----------------|-----------|------------|
|
|
5
|
+
| Exposed API key | Git scanning | Rotate immediately |
|
|
6
|
+
| Excessive scopes | Audit logs | Reduce permissions |
|
|
7
|
+
| Missing rotation | Key age check | Schedule rotation |
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
### Service Account Pattern
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
const clients = {
|
|
7
|
+
reader: new VercelClient({
|
|
8
|
+
apiKey: process.env.VERCEL_READ_KEY,
|
|
9
|
+
}),
|
|
10
|
+
writer: new VercelClient({
|
|
11
|
+
apiKey: process.env.VERCEL_WRITE_KEY,
|
|
12
|
+
}),
|
|
13
|
+
};
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Webhook Signature Verification
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import crypto from 'crypto';
|
|
20
|
+
|
|
21
|
+
function verifyWebhookSignature(
|
|
22
|
+
payload: string, signature: string, secret: string
|
|
23
|
+
): boolean {
|
|
24
|
+
const expected = crypto.createHmac('sha256', secret).update(payload).digest('hex');
|
|
25
|
+
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Security Checklist
|
|
30
|
+
|
|
31
|
+
- [ ] API keys in environment variables
|
|
32
|
+
- [ ] `.env` files in `.gitignore`
|
|
33
|
+
- [ ] Different keys for dev/staging/prod
|
|
34
|
+
- [ ] Minimal scopes per environment
|
|
35
|
+
- [ ] Webhook signatures validated
|
|
36
|
+
- [ ] Audit logging enabled
|
|
37
|
+
|
|
38
|
+
### Audit Logging
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
interface AuditEntry {
|
|
42
|
+
timestamp: Date;
|
|
43
|
+
action: string;
|
|
44
|
+
userId: string;
|
|
45
|
+
resource: string;
|
|
46
|
+
result: 'success' | 'failure';
|
|
47
|
+
metadata?: Record<string, any>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function auditLog(entry: Omit<AuditEntry, 'timestamp'>): Promise<void> {
|
|
51
|
+
const log: AuditEntry = { ...entry, timestamp: new Date() };
|
|
52
|
+
|
|
53
|
+
// Log to Vercel analytics
|
|
54
|
+
await vercelClient.track('audit', log);
|
|
55
|
+
|
|
56
|
+
// Also log locally for compliance
|
|
57
|
+
console.log('[AUDIT]', JSON.stringify(log));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Usage
|
|
61
|
+
await auditLog({
|
|
62
|
+
action: 'vercel.api.call',
|
|
63
|
+
userId: currentUser.id,
|
|
64
|
+
resource: '/v1/resource',
|
|
65
|
+
result: 'success',
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
## Implementation Guide
|
|
2
|
+
|
|
3
|
+
### Step 1: Configure Environment Variables
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# .env (NEVER commit to git)
|
|
7
|
+
VERCEL_API_KEY=sk_live_***
|
|
8
|
+
VERCEL_SECRET=***
|
|
9
|
+
|
|
10
|
+
# .gitignore
|
|
11
|
+
.env
|
|
12
|
+
.env.local
|
|
13
|
+
.env.*.local
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Step 2: Implement Secret Rotation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 1. Generate new key in Vercel dashboard
|
|
20
|
+
# 2. Update environment variable
|
|
21
|
+
export VERCEL_API_KEY="new_key_here"
|
|
22
|
+
|
|
23
|
+
# 3. Verify new key works
|
|
24
|
+
curl -H "Authorization: Bearer ${VERCEL_API_KEY}" \
|
|
25
|
+
https://api.vercel.com/health
|
|
26
|
+
|
|
27
|
+
# 4. Revoke old key in dashboard
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Step 3: Apply Least Privilege
|
|
31
|
+
|
|
32
|
+
| Environment | Recommended Scopes |
|
|
33
|
+
|-------------|-------------------|
|
|
34
|
+
| Development | `read, deploy` |
|
|
35
|
+
| Staging | `read, write, deploy` |
|
|
36
|
+
| Production | `read, write, deploy, domains` |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
|