@striae-org/striae 5.2.0 โ†’ 5.3.0

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.
Files changed (105) hide show
  1. package/.env.example +36 -33
  2. package/README.md +5 -46
  3. package/app/components/actions/case-export/core-export.ts +2 -174
  4. package/app/components/actions/case-export/download-handlers.ts +83 -750
  5. package/app/components/actions/case-export/index.ts +6 -30
  6. package/app/components/actions/case-export/metadata-helpers.ts +0 -78
  7. package/app/components/actions/case-export/types-constants.ts +0 -43
  8. package/app/components/actions/case-import/confirmation-import.ts +13 -14
  9. package/app/components/actions/case-import/zip-processing.ts +92 -12
  10. package/app/components/actions/generate-pdf.ts +3 -2
  11. package/app/components/audit/user-audit-viewer.tsx +0 -19
  12. package/app/components/audit/viewer/audit-viewer-header.tsx +0 -33
  13. package/app/components/navbar/case-modals/archive-case-modal.tsx +1 -1
  14. package/app/components/navbar/navbar.tsx +1 -1
  15. package/app/components/sidebar/case-import/case-import.module.css +35 -0
  16. package/app/components/sidebar/case-import/components/CasePreviewSection.tsx +59 -3
  17. package/app/components/sidebar/case-import/components/ConfirmationDialog.tsx +2 -4
  18. package/app/components/sidebar/case-import/components/ConfirmationPreviewSection.tsx +1 -1
  19. package/app/components/sidebar/notes/class-details-shared.ts +2 -2
  20. package/app/components/toast/toast.module.css +36 -0
  21. package/app/components/toast/toast.tsx +6 -2
  22. package/app/components/user/manage-profile.tsx +4 -3
  23. package/app/config-example/config.json +1 -2
  24. package/app/root.tsx +0 -7
  25. package/app/routes/_index.tsx +1 -1
  26. package/app/routes/auth/login.example.tsx +22 -103
  27. package/app/routes/auth/route.ts +1 -1
  28. package/app/routes/striae/striae.tsx +53 -59
  29. package/app/services/firebase/index.ts +0 -3
  30. package/app/types/export.ts +1 -2
  31. package/app/utils/auth/index.ts +0 -1
  32. package/app/utils/data/permissions.ts +3 -2
  33. package/package.json +10 -17
  34. package/public/_headers +0 -4
  35. package/public/_routes.json +0 -1
  36. package/worker-configuration.d.ts +20 -17
  37. package/workers/audit-worker/src/audit-worker.example.ts +9 -806
  38. package/workers/audit-worker/src/config.ts +7 -0
  39. package/workers/audit-worker/src/crypto/data-at-rest.ts +410 -0
  40. package/workers/audit-worker/src/handlers/audit-routes.ts +125 -0
  41. package/workers/audit-worker/src/storage/audit-storage.ts +99 -0
  42. package/workers/audit-worker/src/types.ts +56 -0
  43. package/workers/audit-worker/worker-configuration.d.ts +1 -1
  44. package/workers/audit-worker/wrangler.jsonc.example +1 -1
  45. package/workers/data-worker/src/config.ts +11 -0
  46. package/workers/data-worker/src/data-worker.example.ts +21 -942
  47. package/workers/data-worker/src/handlers/decrypt-export.ts +118 -0
  48. package/workers/data-worker/src/handlers/signing.ts +174 -0
  49. package/workers/data-worker/src/handlers/storage-routes.ts +129 -0
  50. package/workers/data-worker/src/registry/key-registry.ts +368 -0
  51. package/workers/data-worker/src/types.ts +46 -0
  52. package/workers/data-worker/worker-configuration.d.ts +1 -1
  53. package/workers/data-worker/wrangler.jsonc.example +1 -1
  54. package/workers/image-worker/worker-configuration.d.ts +1 -1
  55. package/workers/image-worker/wrangler.jsonc.example +1 -1
  56. package/workers/pdf-worker/worker-configuration.d.ts +2 -3
  57. package/workers/pdf-worker/wrangler.jsonc.example +1 -1
  58. package/workers/user-worker/src/auth.ts +30 -0
  59. package/workers/user-worker/src/cleanup/account-deletion.ts +337 -0
  60. package/workers/user-worker/src/config.ts +4 -0
  61. package/workers/user-worker/src/encryption-utils.ts +25 -0
  62. package/workers/user-worker/src/firebase/admin.ts +152 -0
  63. package/workers/user-worker/src/handlers/user-routes.ts +242 -0
  64. package/workers/user-worker/src/registry/user-kv.ts +172 -0
  65. package/workers/user-worker/src/storage/user-records.ts +34 -0
  66. package/workers/user-worker/src/types.ts +106 -0
  67. package/workers/user-worker/src/user-worker.example.ts +18 -964
  68. package/workers/user-worker/worker-configuration.d.ts +4 -2
  69. package/workers/user-worker/wrangler.jsonc.example +12 -1
  70. package/wrangler.toml.example +1 -1
  71. package/app/components/actions/case-export/data-processing.ts +0 -223
  72. package/app/components/sidebar/case-export/case-export.module.css +0 -418
  73. package/app/components/sidebar/case-export/case-export.tsx +0 -310
  74. package/app/types/exceljs-bare.d.ts +0 -9
  75. package/app/utils/auth/auth.ts +0 -11
  76. package/public/.well-known/security.txt +0 -6
  77. package/public/favicon.ico +0 -0
  78. package/public/icon-256.png +0 -0
  79. package/public/icon-512.png +0 -0
  80. package/public/manifest.json +0 -39
  81. package/public/shortcut.png +0 -0
  82. package/public/social-image.png +0 -0
  83. package/public/vendor/exceljs.LICENSE +0 -22
  84. package/public/vendor/exceljs.bare.min.js +0 -45
  85. package/scripts/deploy-all.sh +0 -166
  86. package/scripts/deploy-config/modules/env-utils.sh +0 -322
  87. package/scripts/deploy-config/modules/keys.sh +0 -404
  88. package/scripts/deploy-config/modules/prompt.sh +0 -372
  89. package/scripts/deploy-config/modules/scaffolding.sh +0 -336
  90. package/scripts/deploy-config/modules/validation.sh +0 -365
  91. package/scripts/deploy-config.sh +0 -236
  92. package/scripts/deploy-pages-secrets.sh +0 -231
  93. package/scripts/deploy-pages.sh +0 -34
  94. package/scripts/deploy-primershear-emails.sh +0 -167
  95. package/scripts/deploy-worker-secrets.sh +0 -374
  96. package/scripts/dev.cjs +0 -23
  97. package/scripts/install-workers.sh +0 -88
  98. package/scripts/run-eslint.cjs +0 -43
  99. package/scripts/update-compatibility-dates.cjs +0 -124
  100. package/scripts/update-markdown-versions.cjs +0 -43
  101. package/workers/keys-worker/package.json +0 -18
  102. package/workers/keys-worker/src/keys.example.ts +0 -67
  103. package/workers/keys-worker/src/keys.ts +0 -67
  104. package/workers/keys-worker/worker-configuration.d.ts +0 -7447
  105. package/workers/keys-worker/wrangler.jsonc.example +0 -15
@@ -1,365 +0,0 @@
1
- #!/bin/bash
2
-
3
- validate_data_at_rest_encryption_settings() {
4
- local enabled_normalized
5
- enabled_normalized=$(printf '%s' "${DATA_AT_REST_ENCRYPTION_ENABLED:-false}" | tr '[:upper:]' '[:lower:]')
6
-
7
- if [ "$enabled_normalized" != "1" ] && [ "$enabled_normalized" != "true" ] && [ "$enabled_normalized" != "yes" ] && [ "$enabled_normalized" != "on" ]; then
8
- echo -e "${RED}โŒ Error: DATA_AT_REST_ENCRYPTION_ENABLED must be true because data-at-rest encryption is mandatory${NC}"
9
- exit 1
10
- fi
11
-
12
- local has_legacy_private_key=false
13
- local has_registry_keys_json=false
14
-
15
- if [ -n "$DATA_AT_REST_ENCRYPTION_PRIVATE_KEY" ] && ! is_placeholder "$DATA_AT_REST_ENCRYPTION_PRIVATE_KEY"; then
16
- has_legacy_private_key=true
17
- fi
18
-
19
- if [ -n "$DATA_AT_REST_ENCRYPTION_KEYS_JSON" ] && ! is_placeholder "$DATA_AT_REST_ENCRYPTION_KEYS_JSON"; then
20
- has_registry_keys_json=true
21
- fi
22
-
23
- if [ "$has_legacy_private_key" != "true" ] && [ "$has_registry_keys_json" != "true" ]; then
24
- echo -e "${RED}โŒ Error: either DATA_AT_REST_ENCRYPTION_PRIVATE_KEY or DATA_AT_REST_ENCRYPTION_KEYS_JSON is required when data-at-rest encryption is enabled${NC}"
25
- exit 1
26
- fi
27
-
28
- if [ -z "$DATA_AT_REST_ENCRYPTION_PUBLIC_KEY" ] || is_placeholder "$DATA_AT_REST_ENCRYPTION_PUBLIC_KEY"; then
29
- echo -e "${RED}โŒ Error: DATA_AT_REST_ENCRYPTION_PUBLIC_KEY is required when data-at-rest encryption is enabled${NC}"
30
- exit 1
31
- fi
32
-
33
- if [ -z "$DATA_AT_REST_ENCRYPTION_KEY_ID" ] || is_placeholder "$DATA_AT_REST_ENCRYPTION_KEY_ID"; then
34
- echo -e "${RED}โŒ Error: DATA_AT_REST_ENCRYPTION_KEY_ID is required when data-at-rest encryption is enabled${NC}"
35
- exit 1
36
- fi
37
- }
38
-
39
- validate_user_kv_encryption_settings() {
40
- local has_legacy_private_key=false
41
- local has_registry_keys_json=false
42
- local write_endpoints_enabled_normalized
43
-
44
- if [ -n "$USER_KV_ENCRYPTION_PRIVATE_KEY" ] && ! is_placeholder "$USER_KV_ENCRYPTION_PRIVATE_KEY"; then
45
- has_legacy_private_key=true
46
- fi
47
-
48
- if [ -n "$USER_KV_ENCRYPTION_KEYS_JSON" ] && ! is_placeholder "$USER_KV_ENCRYPTION_KEYS_JSON"; then
49
- has_registry_keys_json=true
50
- fi
51
-
52
- if [ "$has_legacy_private_key" != "true" ] && [ "$has_registry_keys_json" != "true" ]; then
53
- echo -e "${RED}โŒ Error: either USER_KV_ENCRYPTION_PRIVATE_KEY or USER_KV_ENCRYPTION_KEYS_JSON is required${NC}"
54
- exit 1
55
- fi
56
-
57
- # Defaults to enabled to preserve current behavior unless explicitly set false for read-only deployments.
58
- write_endpoints_enabled_normalized=$(printf '%s' "${USER_KV_WRITE_ENDPOINTS_ENABLED:-true}" | tr '[:upper:]' '[:lower:]')
59
-
60
- if [ "$write_endpoints_enabled_normalized" = "1" ] || [ "$write_endpoints_enabled_normalized" = "true" ] || [ "$write_endpoints_enabled_normalized" = "yes" ] || [ "$write_endpoints_enabled_normalized" = "on" ]; then
61
- if [ -z "$USER_KV_ENCRYPTION_PUBLIC_KEY" ] || is_placeholder "$USER_KV_ENCRYPTION_PUBLIC_KEY"; then
62
- echo -e "${RED}โŒ Error: USER_KV_ENCRYPTION_PUBLIC_KEY is required when USER_KV_WRITE_ENDPOINTS_ENABLED is true${NC}"
63
- exit 1
64
- fi
65
-
66
- if [ -z "$USER_KV_ENCRYPTION_KEY_ID" ] || is_placeholder "$USER_KV_ENCRYPTION_KEY_ID"; then
67
- echo -e "${RED}โŒ Error: USER_KV_ENCRYPTION_KEY_ID is required when USER_KV_WRITE_ENDPOINTS_ENABLED is true${NC}"
68
- exit 1
69
- fi
70
- fi
71
- }
72
-
73
- # Validate required variables
74
- required_vars=(
75
- # Core Cloudflare Configuration
76
- "ACCOUNT_ID"
77
-
78
- # Shared Authentication & Storage
79
- "USER_DB_AUTH"
80
- "R2_KEY_SECRET"
81
- "IMAGES_API_TOKEN"
82
-
83
- # Firebase Auth Configuration
84
- "API_KEY"
85
- "AUTH_DOMAIN"
86
- "PROJECT_ID"
87
- "STORAGE_BUCKET"
88
- "MESSAGING_SENDER_ID"
89
- "APP_ID"
90
- "MEASUREMENT_ID"
91
- "FIREBASE_SERVICE_ACCOUNT_EMAIL"
92
- "FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY"
93
-
94
- # Pages Configuration
95
- "PAGES_PROJECT_NAME"
96
- "PAGES_CUSTOM_DOMAIN"
97
-
98
- # Worker Names (required for config replacement)
99
- "KEYS_WORKER_NAME"
100
- "USER_WORKER_NAME"
101
- "DATA_WORKER_NAME"
102
- "AUDIT_WORKER_NAME"
103
- "IMAGES_WORKER_NAME"
104
- "PDF_WORKER_NAME"
105
-
106
- # Worker Domains (required for proxy/env secrets and worker fallbacks)
107
- "KEYS_WORKER_DOMAIN"
108
- "USER_WORKER_DOMAIN"
109
- "DATA_WORKER_DOMAIN"
110
- "AUDIT_WORKER_DOMAIN"
111
- "IMAGES_WORKER_DOMAIN"
112
- "PDF_WORKER_DOMAIN"
113
-
114
- # Storage Configuration (required for config replacement)
115
- "DATA_BUCKET_NAME"
116
- "AUDIT_BUCKET_NAME"
117
- "FILES_BUCKET_NAME"
118
- "KV_STORE_ID"
119
-
120
- # Worker-Specific Secrets (required for deployment)
121
- "KEYS_AUTH"
122
- "PDF_WORKER_AUTH"
123
- "IMAGE_SIGNED_URL_SECRET"
124
- "BROWSER_API_TOKEN"
125
- "MANIFEST_SIGNING_PRIVATE_KEY"
126
- "MANIFEST_SIGNING_KEY_ID"
127
- "MANIFEST_SIGNING_PUBLIC_KEY"
128
- "EXPORT_ENCRYPTION_PRIVATE_KEY"
129
- "EXPORT_ENCRYPTION_KEY_ID"
130
- "EXPORT_ENCRYPTION_PUBLIC_KEY"
131
- )
132
-
133
- validate_required_vars() {
134
- echo -e "${YELLOW}๐Ÿ” Validating required environment variables...${NC}"
135
- for var in "${required_vars[@]}"; do
136
- if [ -z "${!var}" ] || is_placeholder "${!var}"; then
137
- echo -e "${RED}โŒ Error: $var is not set in .env file or is a placeholder${NC}"
138
- exit 1
139
- fi
140
- done
141
- echo -e "${GREEN}โœ… All required variables found${NC}"
142
- }
143
-
144
- assert_file_exists() {
145
- local file_path=$1
146
-
147
- if [ ! -f "$file_path" ]; then
148
- echo -e "${RED}โŒ Error: required file is missing: $file_path${NC}"
149
- exit 1
150
- fi
151
- }
152
-
153
- assert_contains_literal() {
154
- local file_path=$1
155
- local literal=$2
156
- local description=$3
157
-
158
- if ! grep -Fq -- "$literal" "$file_path"; then
159
- echo -e "${RED}โŒ Error: ${description}${NC}"
160
- echo -e "${YELLOW} Expected to find '$literal' in $file_path${NC}"
161
- exit 1
162
- fi
163
- }
164
-
165
- assert_no_match_in_file() {
166
- local file_path=$1
167
- local pattern=$2
168
- local description=$3
169
- local matches
170
-
171
- matches=$(grep -En "$pattern" "$file_path" | head -n 3 || true)
172
- if [ -n "$matches" ]; then
173
- echo -e "${RED}โŒ Error: ${description}${NC}"
174
- echo -e "${YELLOW} First matching lines in $file_path:${NC}"
175
- echo "$matches"
176
- exit 1
177
- fi
178
- }
179
-
180
- validate_json_file() {
181
- local file_path=$1
182
-
183
- if ! node -e "const fs=require('fs'); JSON.parse(fs.readFileSync(process.argv[1], 'utf8'));" "$file_path" > /dev/null 2>&1; then
184
- echo -e "${RED}โŒ Error: invalid JSON in $file_path${NC}"
185
- exit 1
186
- fi
187
- }
188
-
189
- validate_domain_var() {
190
- local var_name=$1
191
- local value="${!var_name}"
192
- local normalized
193
-
194
- value=$(strip_carriage_returns "$value")
195
- normalized=$(normalize_domain_value "$value")
196
-
197
- if [ -z "$value" ] || is_placeholder "$value"; then
198
- echo -e "${RED}โŒ Error: $var_name is missing or placeholder${NC}"
199
- exit 1
200
- fi
201
-
202
- if [ "$value" != "$normalized" ]; then
203
- echo -e "${RED}โŒ Error: $var_name must not include protocol, trailing slash, or surrounding whitespace${NC}"
204
- echo -e "${YELLOW} Use '$normalized' instead${NC}"
205
- exit 1
206
- fi
207
-
208
- if [[ "$value" == */* ]]; then
209
- echo -e "${RED}โŒ Error: $var_name must be a bare domain (no path segments)${NC}"
210
- exit 1
211
- fi
212
- }
213
-
214
- validate_env_value_formats() {
215
- echo -e "${YELLOW}๐Ÿ” Validating environment value formats...${NC}"
216
-
217
- validate_domain_var "PAGES_CUSTOM_DOMAIN"
218
- validate_domain_var "KEYS_WORKER_DOMAIN"
219
- validate_domain_var "USER_WORKER_DOMAIN"
220
- validate_domain_var "DATA_WORKER_DOMAIN"
221
- validate_domain_var "AUDIT_WORKER_DOMAIN"
222
- validate_domain_var "IMAGES_WORKER_DOMAIN"
223
- validate_domain_var "PDF_WORKER_DOMAIN"
224
-
225
- if ! [[ "$KV_STORE_ID" =~ ^([0-9a-fA-F]{32}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$ ]]; then
226
- echo -e "${RED}โŒ Error: KV_STORE_ID must be a 32-character hex namespace ID (or UUID format)${NC}"
227
- exit 1
228
- fi
229
-
230
- if [[ "$ACCOUNT_ID" =~ [[:space:]] ]]; then
231
- echo -e "${RED}โŒ Error: ACCOUNT_ID must not contain whitespace${NC}"
232
- exit 1
233
- fi
234
-
235
- echo -e "${GREEN}โœ… Environment value formats look valid${NC}"
236
- }
237
-
238
- validate_env_file_entries() {
239
- local var_name
240
- local escaped_var_name
241
- local count
242
-
243
- echo -e "${YELLOW}๐Ÿ” Verifying required .env entries...${NC}"
244
- for var_name in "${required_vars[@]}"; do
245
- escaped_var_name=$(escape_for_sed_pattern "$var_name")
246
- count=$(grep -c "^$escaped_var_name=" .env || true)
247
-
248
- if [ "$count" -lt 1 ]; then
249
- echo -e "${RED}โŒ Error: missing .env entry for $var_name${NC}"
250
- exit 1
251
- fi
252
- done
253
- echo -e "${GREEN}โœ… Required .env entries found${NC}"
254
- }
255
-
256
- validate_generated_configs() {
257
- echo -e "${YELLOW}๐Ÿ” Running generated configuration checkpoint validations...${NC}"
258
-
259
- local required_files=(
260
- "wrangler.toml"
261
- "app/config/config.json"
262
- "app/config/firebase.ts"
263
- "app/config/admin-service.json"
264
- "app/routes/auth/login.tsx"
265
- "app/routes/auth/login.module.css"
266
- "workers/audit-worker/wrangler.jsonc"
267
- "workers/data-worker/wrangler.jsonc"
268
- "workers/image-worker/wrangler.jsonc"
269
- "workers/keys-worker/wrangler.jsonc"
270
- "workers/pdf-worker/wrangler.jsonc"
271
- "workers/user-worker/wrangler.jsonc"
272
- "workers/audit-worker/src/audit-worker.ts"
273
- "workers/data-worker/src/data-worker.ts"
274
- "workers/image-worker/src/image-worker.ts"
275
- "workers/keys-worker/src/keys.ts"
276
- "workers/pdf-worker/src/pdf-worker.ts"
277
- "workers/user-worker/src/user-worker.ts"
278
- )
279
-
280
- local file_path
281
- for file_path in "${required_files[@]}"; do
282
- assert_file_exists "$file_path"
283
- done
284
-
285
- validate_json_file "app/config/config.json"
286
- validate_json_file "app/config/admin-service.json"
287
-
288
- assert_contains_literal "wrangler.toml" "\"$PAGES_PROJECT_NAME\"" "PAGES_PROJECT_NAME was not applied to wrangler.toml"
289
-
290
- assert_contains_literal "workers/keys-worker/wrangler.jsonc" "$KEYS_WORKER_NAME" "KEYS_WORKER_NAME was not applied"
291
- assert_contains_literal "workers/user-worker/wrangler.jsonc" "$USER_WORKER_NAME" "USER_WORKER_NAME was not applied"
292
- assert_contains_literal "workers/data-worker/wrangler.jsonc" "$DATA_WORKER_NAME" "DATA_WORKER_NAME was not applied"
293
- assert_contains_literal "workers/audit-worker/wrangler.jsonc" "$AUDIT_WORKER_NAME" "AUDIT_WORKER_NAME was not applied"
294
- assert_contains_literal "workers/image-worker/wrangler.jsonc" "$IMAGES_WORKER_NAME" "IMAGES_WORKER_NAME was not applied"
295
- assert_contains_literal "workers/pdf-worker/wrangler.jsonc" "$PDF_WORKER_NAME" "PDF_WORKER_NAME was not applied"
296
-
297
- assert_contains_literal "workers/keys-worker/wrangler.jsonc" "$ACCOUNT_ID" "ACCOUNT_ID missing in keys worker config"
298
- assert_contains_literal "workers/user-worker/wrangler.jsonc" "$ACCOUNT_ID" "ACCOUNT_ID missing in user worker config"
299
- assert_contains_literal "workers/data-worker/wrangler.jsonc" "$ACCOUNT_ID" "ACCOUNT_ID missing in data worker config"
300
- assert_contains_literal "workers/audit-worker/wrangler.jsonc" "$ACCOUNT_ID" "ACCOUNT_ID missing in audit worker config"
301
- assert_contains_literal "workers/image-worker/wrangler.jsonc" "$ACCOUNT_ID" "ACCOUNT_ID missing in image worker config"
302
- assert_contains_literal "workers/pdf-worker/wrangler.jsonc" "$ACCOUNT_ID" "ACCOUNT_ID missing in pdf worker config"
303
-
304
- assert_contains_literal "workers/data-worker/wrangler.jsonc" "$DATA_BUCKET_NAME" "DATA_BUCKET_NAME missing in data worker config"
305
- assert_contains_literal "workers/audit-worker/wrangler.jsonc" "$AUDIT_BUCKET_NAME" "AUDIT_BUCKET_NAME missing in audit worker config"
306
- assert_contains_literal "workers/image-worker/wrangler.jsonc" "$FILES_BUCKET_NAME" "FILES_BUCKET_NAME missing in image worker config"
307
- assert_contains_literal "workers/user-worker/wrangler.jsonc" "$KV_STORE_ID" "KV_STORE_ID missing in user worker config"
308
-
309
- assert_contains_literal "app/config/config.json" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in app/config/config.json"
310
- assert_contains_literal "app/config/config.json" "$EXPORT_ENCRYPTION_KEY_ID" "EXPORT_ENCRYPTION_KEY_ID missing in app/config/config.json"
311
- assert_contains_literal "app/config/config.json" "\"export_encryption_public_key\":" "export_encryption_public_key missing in app/config/config.json"
312
- assert_contains_literal "app/routes/auth/login.tsx" "const APP_CANONICAL_ORIGIN = 'https://$PAGES_CUSTOM_DOMAIN';" "PAGES_CUSTOM_DOMAIN missing in app/routes/auth/login.tsx canonical origin"
313
-
314
- assert_contains_literal "app/config/firebase.ts" "$API_KEY" "API_KEY missing in app/config/firebase.ts"
315
- assert_contains_literal "app/config/firebase.ts" "$AUTH_DOMAIN" "AUTH_DOMAIN missing in app/config/firebase.ts"
316
- assert_contains_literal "app/config/firebase.ts" "$PROJECT_ID" "PROJECT_ID missing in app/config/firebase.ts"
317
- assert_contains_literal "app/config/firebase.ts" "$STORAGE_BUCKET" "STORAGE_BUCKET missing in app/config/firebase.ts"
318
- assert_contains_literal "app/config/firebase.ts" "$MESSAGING_SENDER_ID" "MESSAGING_SENDER_ID missing in app/config/firebase.ts"
319
- assert_contains_literal "app/config/firebase.ts" "$APP_ID" "APP_ID missing in app/config/firebase.ts"
320
- assert_contains_literal "app/config/firebase.ts" "$MEASUREMENT_ID" "MEASUREMENT_ID missing in app/config/firebase.ts"
321
-
322
- assert_contains_literal "workers/audit-worker/src/audit-worker.ts" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in audit-worker source"
323
- assert_contains_literal "workers/data-worker/src/data-worker.ts" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in data-worker source"
324
- assert_contains_literal "workers/image-worker/src/image-worker.ts" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in image-worker source"
325
- assert_contains_literal "workers/keys-worker/src/keys.ts" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in keys-worker source"
326
- assert_contains_literal "workers/pdf-worker/src/pdf-worker.ts" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in pdf-worker source"
327
- assert_contains_literal "workers/user-worker/src/user-worker.ts" "https://$PAGES_CUSTOM_DOMAIN" "PAGES_CUSTOM_DOMAIN missing in user-worker source"
328
-
329
- local placeholder_pattern
330
- placeholder_pattern="(\"(ACCOUNT_ID|PAGES_PROJECT_NAME|PAGES_CUSTOM_DOMAIN|KEYS_WORKER_NAME|USER_WORKER_NAME|DATA_WORKER_NAME|AUDIT_WORKER_NAME|IMAGES_WORKER_NAME|PDF_WORKER_NAME|KEYS_WORKER_DOMAIN|USER_WORKER_DOMAIN|DATA_WORKER_DOMAIN|AUDIT_WORKER_DOMAIN|IMAGES_WORKER_DOMAIN|PDF_WORKER_DOMAIN|DATA_BUCKET_NAME|AUDIT_BUCKET_NAME|FILES_BUCKET_NAME|KV_STORE_ID|MANIFEST_SIGNING_KEY_ID|MANIFEST_SIGNING_PUBLIC_KEY|EXPORT_ENCRYPTION_KEY_ID|EXPORT_ENCRYPTION_PUBLIC_KEY|YOUR_FIREBASE_API_KEY|YOUR_FIREBASE_AUTH_DOMAIN|YOUR_FIREBASE_PROJECT_ID|YOUR_FIREBASE_STORAGE_BUCKET|YOUR_FIREBASE_MESSAGING_SENDER_ID|YOUR_FIREBASE_APP_ID|YOUR_FIREBASE_MEASUREMENT_ID)\"|'(PAGES_CUSTOM_DOMAIN|DATA_WORKER_DOMAIN|IMAGES_WORKER_DOMAIN)')"
331
-
332
- local files_to_scan=(
333
- "wrangler.toml"
334
- "workers/audit-worker/wrangler.jsonc"
335
- "workers/data-worker/wrangler.jsonc"
336
- "workers/image-worker/wrangler.jsonc"
337
- "workers/keys-worker/wrangler.jsonc"
338
- "workers/pdf-worker/wrangler.jsonc"
339
- "workers/user-worker/wrangler.jsonc"
340
- "workers/audit-worker/src/audit-worker.ts"
341
- "workers/data-worker/src/data-worker.ts"
342
- "workers/image-worker/src/image-worker.ts"
343
- "workers/keys-worker/src/keys.ts"
344
- "workers/pdf-worker/src/pdf-worker.ts"
345
- "workers/user-worker/src/user-worker.ts"
346
- "app/config/config.json"
347
- "app/config/firebase.ts"
348
- "app/routes/auth/login.tsx"
349
- )
350
-
351
- for file_path in "${files_to_scan[@]}"; do
352
- assert_no_match_in_file "$file_path" "$placeholder_pattern" "Unresolved placeholder token found after config update"
353
- done
354
-
355
- echo -e "${GREEN}โœ… Generated configuration checkpoint validation passed${NC}"
356
- }
357
-
358
- run_validation_checkpoint() {
359
- validate_required_vars
360
- validate_env_value_formats
361
- validate_env_file_entries
362
- validate_data_at_rest_encryption_settings
363
- validate_user_kv_encryption_settings
364
- validate_generated_configs
365
- }
@@ -1,236 +0,0 @@
1
- #!/bin/bash
2
-
3
- # ===================================
4
- # STRIAE CONFIGURATION SETUP SCRIPT
5
- # ===================================
6
- # This script sets up all configuration files and replaces placeholders
7
- # Run this BEFORE installing worker dependencies to avoid wrangler validation errors
8
-
9
- set -e
10
- set -o pipefail
11
-
12
- # Colors for output
13
- RED='\033[0;31m'
14
- GREEN='\033[0;32m'
15
- YELLOW='\033[1;33m'
16
- BLUE='\033[0;34m'
17
- NC='\033[0m' # No Color
18
-
19
- echo -e "${BLUE}โš™๏ธ Striae Configuration Setup Script${NC}"
20
- echo "====================================="
21
-
22
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
24
- cd "$PROJECT_ROOT"
25
-
26
- trap 'echo -e "\n${RED}โŒ deploy-config.sh failed near line ${LINENO}${NC}"' ERR
27
-
28
- update_env=false
29
- show_help=false
30
- validate_only=false
31
- force_rotate_keys=false
32
- for arg in "$@"; do
33
- case "$arg" in
34
- -h|--help)
35
- show_help=true
36
- ;;
37
- --update-env)
38
- update_env=true
39
- ;;
40
- --validate-only)
41
- validate_only=true
42
- ;;
43
- --force-rotate-keys)
44
- force_rotate_keys=true
45
- ;;
46
- *)
47
- echo -e "${RED}โŒ Unknown option: $arg${NC}"
48
- echo "Use --help to see supported options."
49
- exit 1
50
- ;;
51
- esac
52
- done
53
-
54
- if [ "$update_env" = "true" ] && [ "$validate_only" = "true" ]; then
55
- echo -e "${RED}โŒ --update-env and --validate-only cannot be used together${NC}"
56
- exit 1
57
- fi
58
-
59
- if [ "$force_rotate_keys" = "true" ] && [ "$validate_only" = "true" ]; then
60
- echo -e "${RED}โŒ --force-rotate-keys and --validate-only cannot be used together${NC}"
61
- exit 1
62
- fi
63
-
64
- if [ "$show_help" = "true" ]; then
65
- echo "Usage: bash ./scripts/deploy-config.sh [--update-env] [--validate-only] [--force-rotate-keys]"
66
- echo ""
67
- echo "Options:"
68
- echo " --update-env Reset .env from .env.example and overwrite configs"
69
- echo " --validate-only Validate current .env and generated config files without modifying them"
70
- echo " --force-rotate-keys Force regeneration of all encryption/signing key pairs without prompts"
71
- echo " -h, --help Show this help message"
72
- exit 0
73
- fi
74
-
75
- if [ "$update_env" = "true" ]; then
76
- echo -e "${YELLOW}โš ๏ธ Update-env mode: overwriting configs and resetting .env values from template${NC}"
77
- fi
78
-
79
- if [ "$force_rotate_keys" = "true" ]; then
80
- echo -e "${YELLOW}โš ๏ธ Force-rotate-keys mode: all encryption/signing key pairs will be regenerated without prompts${NC}"
81
- fi
82
-
83
- require_command() {
84
- local cmd=$1
85
- if ! command -v "$cmd" > /dev/null 2>&1; then
86
- echo -e "${RED}โŒ Error: required command '$cmd' is not installed or not in PATH${NC}"
87
- exit 1
88
- fi
89
- }
90
-
91
- require_command node
92
- require_command sed
93
- require_command awk
94
- require_command grep
95
-
96
- is_placeholder() {
97
- local value="$1"
98
- local normalized
99
-
100
- normalized=$(printf '%s' "$value" | tr -d '\r' | tr '[:upper:]' '[:lower:]')
101
- normalized=$(printf '%s' "$normalized" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
102
- normalized=${normalized#\"}
103
- normalized=${normalized%\"}
104
-
105
- if [ -z "$normalized" ]; then
106
- return 1
107
- fi
108
-
109
- [[ "$normalized" =~ ^your_[a-z0-9_]+_here$ || \
110
- "$normalized" =~ ^your-[a-z0-9-]+-here$ || \
111
- "$normalized" == "placeholder" || \
112
- "$normalized" == "changeme" || \
113
- "$normalized" == "replace_me" || \
114
- "$normalized" == "replace-me" ]]
115
- }
116
-
117
- # Check if .env file exists
118
- env_created_from_example=false
119
- preserved_domain_env_file=""
120
-
121
- if [ -f ".env" ]; then
122
- preserved_domain_env_file=".env"
123
- fi
124
-
125
- if [ "$update_env" = "true" ]; then
126
- if [ -f ".env" ]; then
127
- cp .env .env.backup
128
- preserved_domain_env_file=".env.backup"
129
- echo -e "${GREEN}๐Ÿ“„ Existing .env backed up to .env.backup${NC}"
130
- fi
131
-
132
- if [ -f ".env.example" ]; then
133
- cp ".env.example" ".env"
134
- echo -e "${GREEN}โœ… .env file reset from .env.example${NC}"
135
- env_created_from_example=true
136
- else
137
- echo -e "${RED}โŒ Error: .env.example file not found!${NC}"
138
- exit 1
139
- fi
140
- elif [ ! -f ".env" ]; then
141
- if [ "$validate_only" = "true" ]; then
142
- echo -e "${RED}โŒ Error: .env file not found. --validate-only does not create files.${NC}"
143
- echo -e "${YELLOW}Run deploy-config without --validate-only first to generate and populate .env.${NC}"
144
- exit 1
145
- fi
146
-
147
- echo -e "${YELLOW}๐Ÿ“„ .env file not found, copying from .env.example...${NC}"
148
- if [ -f ".env.example" ]; then
149
- cp ".env.example" ".env"
150
- echo -e "${GREEN}โœ… .env file created from .env.example${NC}"
151
- env_created_from_example=true
152
- else
153
- echo -e "${RED}โŒ Error: Neither .env nor .env.example file found!${NC}"
154
- echo "Please create a .env.example file or provide a .env file."
155
- exit 1
156
- fi
157
- fi
158
-
159
- # Source the .env file
160
- echo -e "${YELLOW}๐Ÿ“– Loading environment variables from .env...${NC}"
161
- source .env
162
-
163
- DEPLOY_CONFIG_MODULES_DIR="$SCRIPT_DIR/deploy-config/modules"
164
- DEPLOY_CONFIG_ENV_UTILS_MODULE="$DEPLOY_CONFIG_MODULES_DIR/env-utils.sh"
165
-
166
- if [ ! -f "$DEPLOY_CONFIG_ENV_UTILS_MODULE" ]; then
167
- echo -e "${RED}โŒ Error: Required deploy-config module not found: $DEPLOY_CONFIG_ENV_UTILS_MODULE${NC}"
168
- exit 1
169
- fi
170
-
171
- source "$DEPLOY_CONFIG_ENV_UTILS_MODULE"
172
-
173
- DEPLOY_CONFIG_KEYS_MODULE="$DEPLOY_CONFIG_MODULES_DIR/keys.sh"
174
- DEPLOY_CONFIG_VALIDATION_MODULE="$DEPLOY_CONFIG_MODULES_DIR/validation.sh"
175
- DEPLOY_CONFIG_SCAFFOLDING_MODULE="$DEPLOY_CONFIG_MODULES_DIR/scaffolding.sh"
176
- DEPLOY_CONFIG_PROMPT_MODULE="$DEPLOY_CONFIG_MODULES_DIR/prompt.sh"
177
-
178
- if [ ! -f "$DEPLOY_CONFIG_KEYS_MODULE" ]; then
179
- echo -e "${RED}โŒ Error: Required deploy-config module not found: $DEPLOY_CONFIG_KEYS_MODULE${NC}"
180
- exit 1
181
- fi
182
-
183
- if [ ! -f "$DEPLOY_CONFIG_VALIDATION_MODULE" ]; then
184
- echo -e "${RED}โŒ Error: Required deploy-config module not found: $DEPLOY_CONFIG_VALIDATION_MODULE${NC}"
185
- exit 1
186
- fi
187
-
188
- if [ ! -f "$DEPLOY_CONFIG_SCAFFOLDING_MODULE" ]; then
189
- echo -e "${RED}โŒ Error: Required deploy-config module not found: $DEPLOY_CONFIG_SCAFFOLDING_MODULE${NC}"
190
- exit 1
191
- fi
192
-
193
- if [ ! -f "$DEPLOY_CONFIG_PROMPT_MODULE" ]; then
194
- echo -e "${RED}โŒ Error: Required deploy-config module not found: $DEPLOY_CONFIG_PROMPT_MODULE${NC}"
195
- exit 1
196
- fi
197
-
198
- source "$DEPLOY_CONFIG_KEYS_MODULE"
199
- source "$DEPLOY_CONFIG_VALIDATION_MODULE"
200
- source "$DEPLOY_CONFIG_SCAFFOLDING_MODULE"
201
- source "$DEPLOY_CONFIG_PROMPT_MODULE"
202
-
203
- if [ "$validate_only" = "true" ]; then
204
- echo -e "\n${BLUE}๐Ÿงช Validate-only mode enabled${NC}"
205
- run_validation_checkpoint
206
- echo -e "\n${GREEN}๐ŸŽ‰ Configuration validation completed successfully!${NC}"
207
- exit 0
208
- fi
209
-
210
-
211
- # Copy example configuration files
212
- copy_example_configs
213
-
214
- # Load required Firebase admin service credentials from app/config/admin-service.json
215
- load_admin_service_credentials
216
-
217
- # Always prompt for secrets to ensure configuration
218
- prompt_for_secrets
219
-
220
- # Validate after secrets have been configured
221
- validate_required_vars
222
-
223
-
224
- # Update wrangler configurations
225
- update_wrangler_configs
226
-
227
- # Validate generated files and values after replacements
228
- run_validation_checkpoint
229
-
230
- echo -e "\n${GREEN}๐ŸŽ‰ Configuration setup completed!${NC}"
231
- echo -e "${BLUE}๐Ÿ“ Next Steps:${NC}"
232
- echo " 1. Install worker dependencies"
233
- echo " 2. Deploy workers"
234
- echo " 3. Deploy worker secrets"
235
- echo " 4. Deploy pages"
236
- echo -e "\n${GREEN}โœจ Ready for deployment!${NC}"