forked from Streampay-Org/StreamPay-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.env.example
More file actions
195 lines (179 loc) · 7.75 KB
/
Copy path.env.example
File metadata and controls
195 lines (179 loc) · 7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# =============================================================================
# StreamPay Frontend Environment Configuration
# =============================================================================
#
# SECURITY NOTES:
# - Never commit real credentials to version control
# - Use different secrets for testnet and mainnet
# - CI must use testnet only (enforced by GitHub Actions)
# - JWT_SECRET must be at least 32 characters in production
# - STELLAR_NETWORK is required - no silent fallback to mainnet
#
# =============================================================================
# REQUIRED VARIABLES
# =============================================================================
# Stellar Network Configuration
# Options: testnet, mainnet
# Required: Yes
# Purpose: Selects which Stellar network to use
# Security: CI will fail if set to 'mainnet'
STELLAR_NETWORK=testnet
# JWT Secret for Authentication
# Required: Yes
# Purpose: Signs and verifies JWT tokens for wallet authentication
# Security: Must be at least 32 characters. Do not use default in production.
# Example: Use a secure random string generator
JWT_SECRET=your-super-secret-jwt-key-min-32-chars-change-this
# Allowed browser origins for public API requests
# Required: Yes
# Purpose: Controls CORS access for frontend API calls
# Example: http://localhost:3000
ALLOWED_ORIGINS=http://localhost:3000
# Node Environment
# Required: No (defaults to development)
# Options: development, production, test
# Purpose: Controls application behavior and optimizations
NODE_ENV=development
# =============================================================================
# OPTIONAL VARIABLES
# =============================================================================
# Service Name
# Required: No (defaults to streampay-frontend)
# Purpose: Identifies service in logs and monitoring
SERVICE_NAME=streampay-frontend
# Internal Auth Token
# Required: No
# Purpose: Token for service-to-service authentication
# Security: Only set for internal service communication
INTERNAL_AUTH_TOKEN=
# Anomaly Detection Thresholds
# Required: No (defaults to 50 and 20)
# Purpose: Configures fraud detection limits
ANOMALY_CREATION_THRESHOLD=50
ANOMALY_SETTLE_THRESHOLD=20
# Request Body Size Cap for /api/v2/streams* (POST, PUT, PATCH)
# Required: No (defaults to 262144 = 256 KB)
# Purpose: Middleware rejects requests whose Content-Length exceeds this value
# with a 413 status and a machine-readable error envelope.
# Only write methods on /api/v2/streams* are subject to this cap;
# GET/HEAD/OPTIONS/DELETE and all other paths are unaffected.
# Example: 131072 for a 128 KB cap, 524288 for a 512 KB cap
MAX_STREAM_BODY_BYTES=262144
# Request Body Size Cap for /api/webhooks* (POST, PUT, PATCH)
# Required: No (defaults to 1048576 = 1 MB)
# Purpose: Middleware rejects webhook requests whose Content-Length exceeds this
# value with a 413 status and a machine-readable error envelope.
# Only write methods on /api/webhooks and /api/webhooks/* are subject
# to this cap; all other paths are unaffected.
# Example: 2097152 for a 2 MB cap
MAX_WEBHOOK_BODY_BYTES=1048576
# =============================================================================
# NETWORK PROFILES
# =============================================================================
#
# TESTNET PROFILE:
# - Horizon URL: https://horizon-testnet.stellar.org
# - Passphrase: Test SDF Network ; September 2015
# - Friendbot: Available for funding
# - Explorer: https://stellar.expert/testnet
# - Asset Label: TESTNET (for UI safety)
#
# MAINNET PROFILE:
# - Horizon URL: https://horizon.stellar.org
# - Passphrase: Public Global Stellar Network ; September 2015
# - Friendbot: Not available
# - Explorer: https://stellar.expert
# - Asset Label: (empty)
#
# =============================================================================
# ENVIRONMENT MATRIX
# =============================================================================
#
# Variable | Testnet | Mainnet | CI | Required
# ---------------------|---------|---------|----|----------
# STELLAR_NETWORK | testnet | mainnet | testnet only | Yes
# JWT_SECRET | dev key | prod key | dev key | Yes
# SERVICE_NAME | optional| optional| optional | No
# INTERNAL_AUTH_TOKEN | optional| optional| optional | No
# ANOMALY_*_THRESHOLD | optional| optional| optional | No
#
# =============================================================================
# SETUP INSTRUCTIONS
# =============================================================================
#
# 1. Copy this file to .env.local:
# cp .env.example .env.local
#
# 2. For local development (testnet):
# - Set STELLAR_NETWORK=testnet
# - Set JWT_SECRET to a random string (can be short for dev)
# - Start with: npm run dev
#
# 3. For production deployment (mainnet):
# - Set STELLAR_NETWORK=mainnet
# - Set JWT_SECRET to a secure 32+ character random string
# - Set NODE_ENV=production
# - Deploy via your hosting platform
#
# 4. For CI/CD:
# - CI automatically enforces testnet-only
# - Set secrets in GitHub Actions or your CI platform
# - Never use production secrets in CI
#
# =============================================================================
# KMS AND SIGNING STRATEGY
# =============================================================================
#
# StreamPay never holds raw secret keys in process memory at rest. The
# KMS abstraction lets us swap between a real cloud KMS in production
# and a deterministic mock in development / CI.
#
# Provider options:
# - 'aws-kms' : Production. KMS_KEY_ID and KMS_REGION required.
# Signing latency: ~50-150ms per request.
# Keys never leave AWS; we hold only references.
# - 'local-mock' : Development / CI only. Uses STELLAR_MOCK_SECRET.
# Latency: synchronous, in-process. Never set this
# in production — the app will fail-fast at boot.
KMS_PROVIDER=local-mock
# AWS KMS Configuration (required if provider is 'aws-kms')
KMS_KEY_ID=
KMS_REGION=us-east-1
# Local Mock Configuration
# SECURITY: Never use these in production
STELLAR_MOCK_SECRET=S_MOCK_SECRET_KEY_56_CHARS_LONG_AAAAAAAAAAAAAAAAAAAAAAA
# Per-request deadline for POST /api/internal/reconciliation in milliseconds.
# Invalid or non-positive values fall back to the 30000 default.
RECONCILIATION_TIMEOUT_MS=30000
# =============================================================================
# SECURITY CHECKLIST
# =============================================================================
#
# Before deploying to production:
# [ ] STELLAR_NETWORK is set to 'mainnet' (if deploying to mainnet)
# [ ] JWT_SECRET is at least 32 characters
# [ ] JWT_SECRET is NOT the default value
# [ ] NODE_ENV is set to 'production'
# [ ] No testnet secrets are used with mainnet configuration
# [ ] Horizon URL matches the selected network
# [ ] Internal auth tokens are set if using service mesh
# [ ] Anomaly thresholds are appropriate for your traffic
#
# =============================================================================
# TROUBLESHOOTING
# =============================================================================
#
# Error: "STELLAR_NETWORK environment variable is required"
# Fix: Set STELLAR_NETWORK=testnet or STELLAR_NETWORK=mainnet in .env.local
#
# Error: "JWT_SECRET must be at least 32 characters"
# Fix: Generate a longer secret using: openssl rand -base64 32
#
# Error: "CI environment detected with mainnet network configuration"
# Fix: CI is restricted to testnet. Use testnet in CI or deploy manually.
#
# Error: "Production environment cannot use default JWT_SECRET"
# Fix: Set a custom JWT_SECRET when NODE_ENV=production
#
# Reconciliation cron auth (long random secret; route fails closed if unset)
RECON_CRON_SECRET=