@striae-org/striae 5.2.1 → 5.3.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.
Files changed (117) hide show
  1. package/.env.example +2 -10
  2. package/README.md +5 -46
  3. package/app/components/actions/case-export/core-export.ts +5 -174
  4. package/app/components/actions/case-export/download-handlers.ts +84 -751
  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 +75 -36
  9. package/app/components/actions/case-import/confirmation-package.ts +68 -1
  10. package/app/components/actions/case-import/index.ts +1 -1
  11. package/app/components/actions/case-import/orchestrator.ts +78 -53
  12. package/app/components/actions/case-import/zip-processing.ts +160 -330
  13. package/app/components/actions/generate-pdf.ts +3 -2
  14. package/app/components/audit/user-audit-viewer.tsx +0 -19
  15. package/app/components/audit/viewer/audit-viewer-header.tsx +0 -33
  16. package/app/components/navbar/case-modals/archive-case-modal.tsx +1 -1
  17. package/app/components/navbar/case-modals/export-case-modal.module.css +27 -0
  18. package/app/components/navbar/case-modals/export-case-modal.tsx +132 -0
  19. package/app/components/navbar/case-modals/export-confirmations-modal.module.css +24 -0
  20. package/app/components/navbar/case-modals/export-confirmations-modal.tsx +108 -0
  21. package/app/components/navbar/navbar.tsx +1 -1
  22. package/app/components/sidebar/case-import/case-import.module.css +35 -0
  23. package/app/components/sidebar/case-import/components/CasePreviewSection.tsx +51 -3
  24. package/app/components/sidebar/case-import/components/ConfirmationDialog.tsx +2 -4
  25. package/app/components/sidebar/case-import/components/ConfirmationPreviewSection.tsx +36 -5
  26. package/app/components/sidebar/case-import/hooks/useFilePreview.ts +5 -9
  27. package/app/components/sidebar/case-import/index.ts +1 -4
  28. package/app/components/sidebar/notes/class-details-shared.ts +2 -2
  29. package/app/components/toast/toast.module.css +36 -0
  30. package/app/components/toast/toast.tsx +6 -2
  31. package/app/components/user/manage-profile.tsx +4 -3
  32. package/app/config-example/config.json +1 -2
  33. package/app/root.tsx +0 -7
  34. package/app/routes/_index.tsx +1 -1
  35. package/app/routes/auth/login.example.tsx +22 -103
  36. package/app/routes/auth/login.tsx +22 -103
  37. package/app/routes/auth/route.ts +1 -1
  38. package/app/routes/striae/striae.tsx +117 -59
  39. package/app/services/firebase/index.ts +0 -3
  40. package/app/types/case.ts +1 -0
  41. package/app/types/export.ts +2 -2
  42. package/app/types/import.ts +10 -0
  43. package/app/utils/auth/index.ts +0 -1
  44. package/app/utils/data/permissions.ts +3 -2
  45. package/package.json +9 -16
  46. package/public/_headers +0 -4
  47. package/public/_routes.json +0 -1
  48. package/worker-configuration.d.ts +20 -17
  49. package/workers/audit-worker/src/audit-worker.example.ts +9 -806
  50. package/workers/audit-worker/src/config.ts +7 -0
  51. package/workers/audit-worker/src/crypto/data-at-rest.ts +410 -0
  52. package/workers/audit-worker/src/handlers/audit-routes.ts +125 -0
  53. package/workers/audit-worker/src/storage/audit-storage.ts +99 -0
  54. package/workers/audit-worker/src/types.ts +56 -0
  55. package/workers/audit-worker/worker-configuration.d.ts +1 -1
  56. package/workers/audit-worker/wrangler.jsonc.example +1 -1
  57. package/workers/data-worker/src/config.ts +11 -0
  58. package/workers/data-worker/src/data-worker.example.ts +21 -942
  59. package/workers/data-worker/src/handlers/decrypt-export.ts +118 -0
  60. package/workers/data-worker/src/handlers/signing.ts +174 -0
  61. package/workers/data-worker/src/handlers/storage-routes.ts +129 -0
  62. package/workers/data-worker/src/registry/key-registry.ts +368 -0
  63. package/workers/data-worker/src/types.ts +46 -0
  64. package/workers/data-worker/worker-configuration.d.ts +1 -1
  65. package/workers/data-worker/wrangler.jsonc.example +1 -1
  66. package/workers/image-worker/worker-configuration.d.ts +1 -1
  67. package/workers/image-worker/wrangler.jsonc.example +1 -1
  68. package/workers/pdf-worker/worker-configuration.d.ts +2 -3
  69. package/workers/pdf-worker/wrangler.jsonc.example +1 -1
  70. package/workers/user-worker/src/auth.ts +30 -0
  71. package/workers/user-worker/src/cleanup/account-deletion.ts +337 -0
  72. package/workers/user-worker/src/config.ts +4 -0
  73. package/workers/user-worker/src/encryption-utils.ts +25 -0
  74. package/workers/user-worker/src/firebase/admin.ts +152 -0
  75. package/workers/user-worker/src/handlers/user-routes.ts +242 -0
  76. package/workers/user-worker/src/registry/user-kv.ts +172 -0
  77. package/workers/user-worker/src/storage/user-records.ts +34 -0
  78. package/workers/user-worker/src/types.ts +106 -0
  79. package/workers/user-worker/src/user-worker.example.ts +18 -964
  80. package/workers/user-worker/worker-configuration.d.ts +4 -2
  81. package/workers/user-worker/wrangler.jsonc.example +12 -1
  82. package/wrangler.toml.example +1 -1
  83. package/app/components/actions/case-export/data-processing.ts +0 -223
  84. package/app/components/sidebar/case-export/case-export.module.css +0 -418
  85. package/app/components/sidebar/case-export/case-export.tsx +0 -310
  86. package/app/types/exceljs-bare.d.ts +0 -9
  87. package/app/utils/auth/auth.ts +0 -11
  88. package/public/.well-known/security.txt +0 -6
  89. package/public/favicon.ico +0 -0
  90. package/public/icon-256.png +0 -0
  91. package/public/icon-512.png +0 -0
  92. package/public/manifest.json +0 -39
  93. package/public/shortcut.png +0 -0
  94. package/public/social-image.png +0 -0
  95. package/public/vendor/exceljs.LICENSE +0 -22
  96. package/public/vendor/exceljs.bare.min.js +0 -45
  97. package/scripts/deploy-all.sh +0 -166
  98. package/scripts/deploy-config/modules/env-utils.sh +0 -322
  99. package/scripts/deploy-config/modules/keys.sh +0 -404
  100. package/scripts/deploy-config/modules/prompt.sh +0 -372
  101. package/scripts/deploy-config/modules/scaffolding.sh +0 -344
  102. package/scripts/deploy-config/modules/validation.sh +0 -365
  103. package/scripts/deploy-config.sh +0 -236
  104. package/scripts/deploy-pages-secrets.sh +0 -231
  105. package/scripts/deploy-pages.sh +0 -34
  106. package/scripts/deploy-primershear-emails.sh +0 -167
  107. package/scripts/deploy-worker-secrets.sh +0 -374
  108. package/scripts/dev.cjs +0 -23
  109. package/scripts/install-workers.sh +0 -88
  110. package/scripts/run-eslint.cjs +0 -43
  111. package/scripts/update-compatibility-dates.cjs +0 -124
  112. package/scripts/update-markdown-versions.cjs +0 -43
  113. package/workers/keys-worker/package.json +0 -18
  114. package/workers/keys-worker/src/keys.example.ts +0 -67
  115. package/workers/keys-worker/src/keys.ts +0 -67
  116. package/workers/keys-worker/worker-configuration.d.ts +0 -7447
  117. package/workers/keys-worker/wrangler.jsonc.example +0 -15
@@ -1,374 +0,0 @@
1
- #!/bin/bash
2
-
3
- # ======================================
4
- # STRIAE WORKER SECRETS DEPLOYMENT SCRIPT
5
- # ======================================
6
- # This script deploys environment variables/secrets to Cloudflare Workers
7
- # Run this AFTER workers are deployed to avoid deployment errors
8
-
9
- set -e
10
-
11
- # Colors for output
12
- RED='\033[0;31m'
13
- GREEN='\033[0;32m'
14
- YELLOW='\033[1;33m'
15
- BLUE='\033[0;34m'
16
- NC='\033[0m' # No Color
17
-
18
- echo -e "${BLUE}🔐 Striae Worker Secrets Deployment Script${NC}"
19
- echo "=========================================="
20
-
21
- # Check if .env file exists
22
- if [ ! -f ".env" ]; then
23
- echo -e "${RED}❌ Error: .env file not found!${NC}"
24
- echo "Please copy .env.example to .env and fill in your values."
25
- exit 1
26
- fi
27
-
28
- # Source the .env file
29
- echo -e "${YELLOW}📖 Loading environment variables from .env...${NC}"
30
- source .env
31
-
32
- is_admin_service_placeholder() {
33
- local value="$1"
34
- local normalized=$(echo "$value" | tr '[:upper:]' '[:lower:]')
35
-
36
- [[ -z "$normalized" || "$normalized" == your-* || "$normalized" == *"your_private_key"* ]]
37
- }
38
-
39
- load_required_admin_service_credentials() {
40
- local admin_service_path="app/config/admin-service.json"
41
-
42
- if [ ! -f "$admin_service_path" ]; then
43
- echo -e "${RED}❌ Error: Required Firebase admin service file not found: $admin_service_path${NC}"
44
- echo -e "${YELLOW} Create app/config/admin-service.json before deploying worker secrets.${NC}"
45
- exit 1
46
- fi
47
-
48
- local service_project_id
49
- local service_client_email
50
- local service_private_key
51
-
52
- if ! service_project_id=$(node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1], 'utf8')); process.stdout.write(data.project_id || '');" "$admin_service_path"); then
53
- echo -e "${RED}❌ Error: Could not parse project_id from $admin_service_path${NC}"
54
- exit 1
55
- fi
56
-
57
- if ! service_client_email=$(node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1], 'utf8')); process.stdout.write(data.client_email || '');" "$admin_service_path"); then
58
- echo -e "${RED}❌ Error: Could not parse client_email from $admin_service_path${NC}"
59
- exit 1
60
- fi
61
-
62
- if ! service_private_key=$(node -e "const fs=require('fs'); const data=JSON.parse(fs.readFileSync(process.argv[1], 'utf8')); process.stdout.write(data.private_key || '');" "$admin_service_path"); then
63
- echo -e "${RED}❌ Error: Could not parse private_key from $admin_service_path${NC}"
64
- exit 1
65
- fi
66
-
67
- local normalized_private_key="${service_private_key//$'\r'/}"
68
- normalized_private_key="${normalized_private_key//$'\n'/\\n}"
69
-
70
- if is_admin_service_placeholder "$service_project_id"; then
71
- echo -e "${RED}❌ Error: project_id in $admin_service_path is missing or placeholder${NC}"
72
- exit 1
73
- fi
74
-
75
- if is_admin_service_placeholder "$service_client_email" || [[ "$service_client_email" != *".gserviceaccount.com"* ]]; then
76
- echo -e "${RED}❌ Error: client_email in $admin_service_path is invalid${NC}"
77
- exit 1
78
- fi
79
-
80
- if is_admin_service_placeholder "$normalized_private_key" || [[ "$normalized_private_key" != *"-----BEGIN PRIVATE KEY-----"* ]] || [[ "$normalized_private_key" != *"-----END PRIVATE KEY-----"* ]]; then
81
- echo -e "${RED}❌ Error: private_key in $admin_service_path is invalid${NC}"
82
- exit 1
83
- fi
84
-
85
- PROJECT_ID="$service_project_id"
86
- FIREBASE_SERVICE_ACCOUNT_EMAIL="$service_client_email"
87
- FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY="$normalized_private_key"
88
-
89
- export PROJECT_ID
90
- export FIREBASE_SERVICE_ACCOUNT_EMAIL
91
- export FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY
92
-
93
- echo -e "${GREEN}✅ Loaded Firebase service account credentials from $admin_service_path${NC}"
94
- }
95
-
96
- load_required_admin_service_credentials
97
-
98
- build_user_worker_secret_list() {
99
- local secrets=(
100
- "USER_DB_AUTH"
101
- "R2_KEY_SECRET"
102
- "IMAGES_API_TOKEN"
103
- "DATA_WORKER_DOMAIN"
104
- "IMAGES_WORKER_DOMAIN"
105
- "PROJECT_ID"
106
- "FIREBASE_SERVICE_ACCOUNT_EMAIL"
107
- "FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY"
108
- )
109
-
110
- if [ -n "${USER_KV_ENCRYPTION_PRIVATE_KEY:-}" ]; then
111
- secrets+=("USER_KV_ENCRYPTION_PRIVATE_KEY")
112
- fi
113
-
114
- if [ -n "${USER_KV_ENCRYPTION_KEYS_JSON:-}" ]; then
115
- secrets+=("USER_KV_ENCRYPTION_KEYS_JSON")
116
- fi
117
-
118
- if [ -n "${USER_KV_ENCRYPTION_ACTIVE_KEY_ID:-}" ]; then
119
- secrets+=("USER_KV_ENCRYPTION_ACTIVE_KEY_ID")
120
- fi
121
-
122
- local write_endpoints_enabled_normalized
123
- write_endpoints_enabled_normalized=$(printf '%s' "${USER_KV_WRITE_ENDPOINTS_ENABLED:-true}" | tr '[:upper:]' '[:lower:]')
124
-
125
- if [ "$write_endpoints_enabled_normalized" = "1" ] || [ "$write_endpoints_enabled_normalized" = "true" ] || [ "$write_endpoints_enabled_normalized" = "yes" ] || [ "$write_endpoints_enabled_normalized" = "on" ]; then
126
- if [ -n "${USER_KV_ENCRYPTION_KEY_ID:-}" ]; then
127
- secrets+=("USER_KV_ENCRYPTION_KEY_ID")
128
- fi
129
-
130
- if [ -n "${USER_KV_ENCRYPTION_PUBLIC_KEY:-}" ]; then
131
- secrets+=("USER_KV_ENCRYPTION_PUBLIC_KEY")
132
- fi
133
- fi
134
-
135
- printf '%s\n' "${secrets[@]}"
136
- }
137
-
138
- build_audit_worker_secret_list() {
139
- local secrets=(
140
- "R2_KEY_SECRET"
141
- )
142
-
143
- if [ -n "${DATA_AT_REST_ENCRYPTION_ENABLED:-}" ]; then
144
- secrets+=("DATA_AT_REST_ENCRYPTION_ENABLED")
145
- fi
146
-
147
- if [ -n "${DATA_AT_REST_ENCRYPTION_PRIVATE_KEY:-}" ]; then
148
- secrets+=("DATA_AT_REST_ENCRYPTION_PRIVATE_KEY")
149
- fi
150
-
151
- if [ -n "${DATA_AT_REST_ENCRYPTION_PUBLIC_KEY:-}" ]; then
152
- secrets+=("DATA_AT_REST_ENCRYPTION_PUBLIC_KEY")
153
- fi
154
-
155
- if [ -n "${DATA_AT_REST_ENCRYPTION_KEY_ID:-}" ]; then
156
- secrets+=("DATA_AT_REST_ENCRYPTION_KEY_ID")
157
- fi
158
-
159
- if [ -n "${DATA_AT_REST_ENCRYPTION_KEYS_JSON:-}" ]; then
160
- secrets+=("DATA_AT_REST_ENCRYPTION_KEYS_JSON")
161
- fi
162
-
163
- if [ -n "${DATA_AT_REST_ENCRYPTION_ACTIVE_KEY_ID:-}" ]; then
164
- secrets+=("DATA_AT_REST_ENCRYPTION_ACTIVE_KEY_ID")
165
- fi
166
-
167
- printf '%s\n' "${secrets[@]}"
168
- }
169
-
170
- # Function to set worker secrets
171
- set_worker_secrets() {
172
- local worker_name=$1
173
- local worker_path=$2
174
- shift 2
175
- local secrets=("$@")
176
-
177
- echo -e "\n${BLUE}🔧 Setting secrets for $worker_name...${NC}"
178
-
179
- # Check if worker has a wrangler configuration file
180
- if [ ! -f "$worker_path/wrangler.jsonc" ] && [ ! -f "$worker_path/wrangler.toml" ]; then
181
- echo -e "${RED}❌ Error: No wrangler configuration found for $worker_name${NC}"
182
- echo -e "${YELLOW} Please copy wrangler.jsonc.example to wrangler.jsonc and configure it first.${NC}"
183
- return 1
184
- fi
185
-
186
- # Change to worker directory
187
- pushd "$worker_path" > /dev/null
188
-
189
- # Get the worker name from the configuration file
190
- local config_worker_name
191
- if [ -f "wrangler.jsonc" ]; then
192
- config_worker_name=$(grep -o '"name"[[:space:]]*:[[:space:]]*"[^"]*"' wrangler.jsonc | sed 's/.*"name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
193
- elif [ -f "wrangler.toml" ]; then
194
- config_worker_name=$(grep '^name[[:space:]]*=' wrangler.toml | sed 's/.*=[[:space:]]*["\x27]\([^"\x27]*\)["\x27].*/\1/')
195
- fi
196
-
197
- if [ -z "$config_worker_name" ]; then
198
- echo -e "${RED}❌ Error: Could not determine worker name from configuration${NC}"
199
- popd > /dev/null
200
- return 1
201
- fi
202
-
203
- echo -e "${YELLOW} Using worker name: $config_worker_name${NC}"
204
-
205
- for secret in "${secrets[@]}"; do
206
- echo -e "${YELLOW} Setting $secret...${NC}"
207
- if ! echo "${!secret}" | wrangler secret put "$secret" --name "$config_worker_name"; then
208
- echo -e "${RED}❌ Failed to set $secret for $worker_name${NC}"
209
- popd > /dev/null
210
- return 1
211
- fi
212
- done
213
-
214
- echo -e "${GREEN}✅ $worker_name secrets configured${NC}"
215
- popd > /dev/null
216
- }
217
-
218
- build_data_worker_secret_list() {
219
- local secrets=(
220
- "R2_KEY_SECRET"
221
- "MANIFEST_SIGNING_PRIVATE_KEY"
222
- "MANIFEST_SIGNING_KEY_ID"
223
- "EXPORT_ENCRYPTION_PRIVATE_KEY"
224
- "EXPORT_ENCRYPTION_KEY_ID"
225
- )
226
-
227
- if [ -n "${DATA_AT_REST_ENCRYPTION_ENABLED:-}" ]; then
228
- secrets+=("DATA_AT_REST_ENCRYPTION_ENABLED")
229
- fi
230
-
231
- if [ -n "${DATA_AT_REST_ENCRYPTION_PRIVATE_KEY:-}" ]; then
232
- secrets+=("DATA_AT_REST_ENCRYPTION_PRIVATE_KEY")
233
- fi
234
-
235
- if [ -n "${DATA_AT_REST_ENCRYPTION_PUBLIC_KEY:-}" ]; then
236
- secrets+=("DATA_AT_REST_ENCRYPTION_PUBLIC_KEY")
237
- fi
238
-
239
- if [ -n "${DATA_AT_REST_ENCRYPTION_KEY_ID:-}" ]; then
240
- secrets+=("DATA_AT_REST_ENCRYPTION_KEY_ID")
241
- fi
242
-
243
- if [ -n "${DATA_AT_REST_ENCRYPTION_KEYS_JSON:-}" ]; then
244
- secrets+=("DATA_AT_REST_ENCRYPTION_KEYS_JSON")
245
- fi
246
-
247
- if [ -n "${DATA_AT_REST_ENCRYPTION_ACTIVE_KEY_ID:-}" ]; then
248
- secrets+=("DATA_AT_REST_ENCRYPTION_ACTIVE_KEY_ID")
249
- fi
250
-
251
- if [ -n "${EXPORT_ENCRYPTION_KEYS_JSON:-}" ]; then
252
- secrets+=("EXPORT_ENCRYPTION_KEYS_JSON")
253
- fi
254
-
255
- if [ -n "${EXPORT_ENCRYPTION_ACTIVE_KEY_ID:-}" ]; then
256
- secrets+=("EXPORT_ENCRYPTION_ACTIVE_KEY_ID")
257
- fi
258
-
259
- printf '%s\n' "${secrets[@]}"
260
- }
261
-
262
- build_images_worker_secret_list() {
263
- local secrets=(
264
- "IMAGES_API_TOKEN"
265
- "DATA_AT_REST_ENCRYPTION_PUBLIC_KEY"
266
- "DATA_AT_REST_ENCRYPTION_KEY_ID"
267
- "IMAGE_SIGNED_URL_SECRET"
268
- )
269
-
270
- if [ -n "${DATA_AT_REST_ENCRYPTION_PRIVATE_KEY:-}" ]; then
271
- secrets+=("DATA_AT_REST_ENCRYPTION_PRIVATE_KEY")
272
- fi
273
-
274
- if [ -n "${DATA_AT_REST_ENCRYPTION_KEYS_JSON:-}" ]; then
275
- secrets+=("DATA_AT_REST_ENCRYPTION_KEYS_JSON")
276
- fi
277
-
278
- if [ -n "${DATA_AT_REST_ENCRYPTION_ACTIVE_KEY_ID:-}" ]; then
279
- secrets+=("DATA_AT_REST_ENCRYPTION_ACTIVE_KEY_ID")
280
- fi
281
-
282
- printf '%s\n' "${secrets[@]}"
283
- }
284
-
285
- # Deploy secrets to each worker
286
- echo -e "\n${BLUE}🔐 Deploying secrets to workers...${NC}"
287
-
288
- # Check if workers are configured
289
- echo -e "${YELLOW}🔍 Checking worker configurations...${NC}"
290
- workers_configured=0
291
- total_workers=6
292
-
293
- for worker_dir in workers/*/; do
294
- if [ -f "$worker_dir/wrangler.jsonc" ] || [ -f "$worker_dir/wrangler.toml" ]; then
295
- workers_configured=$((workers_configured + 1))
296
- fi
297
- done
298
-
299
- if [ $workers_configured -eq 0 ]; then
300
- echo -e "${RED}❌ No workers are configured!${NC}"
301
- echo -e "${YELLOW} Please copy wrangler.jsonc.example to wrangler.jsonc in each worker directory and configure them.${NC}"
302
- echo -e "${YELLOW} Then run this script again.${NC}"
303
- exit 1
304
- elif [ $workers_configured -lt $total_workers ]; then
305
- echo -e "${YELLOW}⚠️ Warning: Only $workers_configured of $total_workers workers are configured.${NC}"
306
- echo -e "${YELLOW} Some workers may not have their secrets deployed.${NC}"
307
- fi
308
-
309
- # Audit Worker
310
- audit_worker_secrets=()
311
- while IFS= read -r secret; do
312
- audit_worker_secrets+=("$secret")
313
- done < <(build_audit_worker_secret_list)
314
-
315
- if ! set_worker_secrets "Audit Worker" "workers/audit-worker" "${audit_worker_secrets[@]}"; then
316
- echo -e "${YELLOW}⚠️ Skipping Audit Worker (not configured)${NC}"
317
- fi
318
-
319
- # Keys Worker
320
- if ! set_worker_secrets "Keys Worker" "workers/keys-worker" \
321
- "KEYS_AUTH" "USER_DB_AUTH" "R2_KEY_SECRET" "IMAGES_API_TOKEN" "PDF_WORKER_AUTH"; then
322
- echo -e "${YELLOW}⚠️ Skipping Keys Worker (not configured)${NC}"
323
- fi
324
-
325
- # User Worker
326
- user_worker_secrets=()
327
- while IFS= read -r secret; do
328
- user_worker_secrets+=("$secret")
329
- done < <(build_user_worker_secret_list)
330
-
331
- if ! set_worker_secrets "User Worker" "workers/user-worker" "${user_worker_secrets[@]}"; then
332
- echo -e "${YELLOW}⚠️ Skipping User Worker (not configured)${NC}"
333
- fi
334
-
335
- # Data Worker
336
- data_worker_secrets=()
337
- while IFS= read -r secret; do
338
- data_worker_secrets+=("$secret")
339
- done < <(build_data_worker_secret_list)
340
-
341
- if ! set_worker_secrets "Data Worker" "workers/data-worker" "${data_worker_secrets[@]}"; then
342
- echo -e "${YELLOW}⚠️ Skipping Data Worker (not configured)${NC}"
343
- fi
344
-
345
- # Images Worker
346
- images_worker_secrets=()
347
- while IFS= read -r secret; do
348
- images_worker_secrets+=("$secret")
349
- done < <(build_images_worker_secret_list)
350
-
351
- if ! set_worker_secrets "Images Worker" "workers/image-worker" "${images_worker_secrets[@]}"; then
352
- echo -e "${YELLOW}⚠️ Skipping Images Worker (not configured)${NC}"
353
- fi
354
-
355
- # PDF Worker
356
- if ! set_worker_secrets "PDF Worker" "workers/pdf-worker" \
357
- "PDF_WORKER_AUTH" "ACCOUNT_ID" "BROWSER_API_TOKEN"; then
358
- echo -e "${YELLOW}⚠️ Skipping PDF Worker (not configured)${NC}"
359
- fi
360
-
361
- echo -e "\n${GREEN}🎉 Worker secrets deployment completed!${NC}"
362
-
363
- echo -e "\n${YELLOW}⚠️ WORKER CONFIGURATION REMINDERS:${NC}"
364
- echo " - Copy wrangler.jsonc.example to wrangler.jsonc in each worker directory"
365
- echo " - Configure KV namespace ID in workers/user-worker/wrangler.jsonc"
366
- echo " - Configure R2 bucket name in workers/data-worker/wrangler.jsonc"
367
- echo " - Configure R2 bucket name in workers/audit-worker/wrangler.jsonc"
368
- echo " - Configure R2 bucket name in workers/image-worker/wrangler.jsonc"
369
- echo " - Update ACCOUNT_ID and custom domains in all worker configurations"
370
-
371
- echo -e "\n${BLUE}📝 For manual deployment, use these commands:${NC}"
372
- echo " cd workers/[worker-name]"
373
- echo " wrangler secret put VARIABLE_NAME --name [worker-name]"
374
- echo -e "\n${GREEN}✨ Worker secrets deployment complete!${NC}"
package/scripts/dev.cjs DELETED
@@ -1,23 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { updateMarkdownVersions } = require('./update-markdown-versions.cjs');
4
- const { updateCompatibilityDates } = require('./update-compatibility-dates.cjs');
5
-
6
- // Read the ASCII art file from the filesystem
7
- const asciiArtPath = path.join(__dirname, '..', 'public', 'striae-ascii.txt');
8
- let asciiArt;
9
- try {
10
- asciiArt = fs.readFileSync(asciiArtPath, 'utf8');
11
- } catch (err) {
12
- console.warn(`Warning: Unable to read ASCII art file at ${asciiArtPath}.\n${err.message}`);
13
- asciiArt = "(ASCII art unavailable)\n";
14
- }
15
-
16
- // Pop a lil' logo in the terminal
17
- console.info(asciiArt);
18
-
19
- // Update markdown files with current version
20
- updateMarkdownVersions();
21
-
22
- // Update compatibility dates to current date
23
- updateCompatibilityDates();
@@ -1,88 +0,0 @@
1
- #!/bin/bash
2
-
3
- # ======================================
4
- # STRIAE WORKERS NPM INSTALL SCRIPT
5
- # ======================================
6
- # This script installs npm dependencies for all Striae workers:
7
- # 1. audit-worker
8
- # 2. data-worker
9
- # 3. image-worker
10
- # 4. keys-worker
11
- # 5. pdf-worker
12
- # 6. user-worker
13
-
14
- # Colors for output
15
- RED='\033[0;31m'
16
- GREEN='\033[0;32m'
17
- YELLOW='\033[1;33m'
18
- BLUE='\033[0;34m'
19
- PURPLE='\033[0;35m'
20
- NC='\033[0m' # No Color
21
-
22
- echo -e "${BLUE}📦 Striae Workers NPM Install Script${NC}"
23
- echo "========================================"
24
- echo ""
25
-
26
- # Get the script directory and project root
27
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28
- PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
29
- WORKERS_DIR="$PROJECT_ROOT/workers"
30
-
31
- # Check if workers directory exists
32
- if [ ! -d "$WORKERS_DIR" ]; then
33
- echo -e "${RED}❌ Error: Workers directory not found at $WORKERS_DIR${NC}"
34
- exit 1
35
- fi
36
-
37
- # List of workers
38
- WORKERS=("audit-worker" "data-worker" "image-worker" "keys-worker" "pdf-worker" "user-worker")
39
-
40
- echo -e "${PURPLE}Installing npm dependencies for all workers...${NC}"
41
- echo ""
42
-
43
- # Counter for progress
44
- total=${#WORKERS[@]}
45
- current=0
46
-
47
- # Install dependencies for each worker
48
- for worker in "${WORKERS[@]}"; do
49
- current=$((current + 1))
50
- worker_path="$WORKERS_DIR/$worker"
51
-
52
- echo -e "${YELLOW}[$current/$total] Installing dependencies for $worker...${NC}"
53
-
54
- # Check if worker directory exists
55
- if [ ! -d "$worker_path" ]; then
56
- echo -e "${RED}❌ Warning: Worker directory not found: $worker_path${NC}"
57
- continue
58
- fi
59
-
60
- # Check if package.json exists
61
- if [ ! -f "$worker_path/package.json" ]; then
62
- echo -e "${RED}❌ Warning: package.json not found in $worker_path${NC}"
63
- continue
64
- fi
65
-
66
- # Change to worker directory and install dependencies
67
- cd "$worker_path"
68
-
69
- echo " Running npm install in $worker_path..."
70
- if npm install; then
71
- echo -e "${GREEN}✅ Successfully installed dependencies for $worker${NC}"
72
- else
73
- echo -e "${RED}❌ Failed to install dependencies for $worker${NC}"
74
- exit 1
75
- fi
76
-
77
- echo ""
78
- done
79
-
80
- # Return to original directory
81
- cd "$PROJECT_ROOT"
82
-
83
- echo -e "${GREEN}🎉 All worker dependencies installed successfully!${NC}"
84
- echo ""
85
- echo -e "${BLUE}Summary:${NC}"
86
- echo "- Installed dependencies for $total workers"
87
- echo "- All workers are ready for development/deployment"
88
- echo ""
@@ -1,43 +0,0 @@
1
- const { spawnSync } = require('node:child_process');
2
- const fs = require('node:fs');
3
- const path = require('node:path');
4
-
5
- const eslintApiPath = require.resolve('eslint');
6
- const eslintCliPath = path.resolve(path.dirname(eslintApiPath), '..', 'bin', 'eslint.js');
7
-
8
- const gitignorePath = path.resolve(process.cwd(), '.gitignore');
9
- const ignorePatterns = fs.existsSync(gitignorePath)
10
- ? fs
11
- .readFileSync(gitignorePath, 'utf8')
12
- .split(/\r?\n/)
13
- .map((line) => line.trim())
14
- .filter((line) => line && !line.startsWith('#'))
15
- : [];
16
-
17
- const ignoreArgs = ignorePatterns.flatMap((pattern) => ['--ignore-pattern', pattern]);
18
-
19
- const defaultArgs = [
20
- ...ignoreArgs,
21
- '--cache',
22
- '--cache-location',
23
- './node_modules/.cache/eslint',
24
- '.',
25
- ];
26
-
27
- const passthroughArgs = process.argv.slice(2);
28
- const eslintArgs = passthroughArgs.length > 0 ? passthroughArgs : defaultArgs;
29
-
30
- const result = spawnSync(process.execPath, [eslintCliPath, ...eslintArgs], {
31
- stdio: 'inherit',
32
- env: process.env,
33
- });
34
-
35
- if (typeof result.status === 'number') {
36
- process.exit(result.status);
37
- }
38
-
39
- if (result.error) {
40
- console.error(result.error);
41
- }
42
-
43
- process.exit(1);
@@ -1,124 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
5
-
6
- function getCurrentDate() {
7
- const now = new Date();
8
- const year = now.getFullYear();
9
- const month = String(now.getMonth() + 1).padStart(2, '0');
10
- const day = String(now.getDate()).padStart(2, '0');
11
- return `${year}-${month}-${day}`;
12
- }
13
-
14
- function replaceTomlCompatibilityDate(content, date) {
15
- return content.replace(
16
- /(compatibility_date\s*=\s*")\d{4}-\d{2}-\d{2}(")/,
17
- `$1${date}$2`
18
- );
19
- }
20
-
21
- function replaceJsoncCompatibilityDate(content, date) {
22
- return content.replace(
23
- /("compatibility_date"\s*:\s*")\d{4}-\d{2}-\d{2}(",?)/,
24
- `$1${date}$2`
25
- );
26
- }
27
-
28
- function updateFile(filePath, date, replacer) {
29
- if (!fs.existsSync(filePath)) {
30
- return { filePath, status: 'missing' };
31
- }
32
-
33
- const original = fs.readFileSync(filePath, 'utf8');
34
- const updated = replacer(original, date);
35
-
36
- if (original === updated) {
37
- return { filePath, status: 'unchanged' };
38
- }
39
-
40
- fs.writeFileSync(filePath, updated, 'utf8');
41
- return { filePath, status: 'updated' };
42
- }
43
-
44
- function updateCompatibilityDates(date = getCurrentDate()) {
45
- if (!DATE_PATTERN.test(date)) {
46
- throw new Error(`Invalid date format: ${date}. Use YYYY-MM-DD.`);
47
- }
48
-
49
- const rootDir = path.resolve(__dirname, '..');
50
- const workersDir = path.join(rootDir, 'workers');
51
-
52
- const results = [];
53
-
54
- results.push(
55
- updateFile(
56
- path.join(rootDir, 'wrangler.toml'),
57
- date,
58
- replaceTomlCompatibilityDate
59
- )
60
- );
61
-
62
- results.push(
63
- updateFile(
64
- path.join(rootDir, 'wrangler.toml.example'),
65
- date,
66
- replaceTomlCompatibilityDate
67
- )
68
- );
69
-
70
- if (fs.existsSync(workersDir)) {
71
- const workerDirs = fs
72
- .readdirSync(workersDir, { withFileTypes: true })
73
- .filter((entry) => entry.isDirectory())
74
- .map((entry) => entry.name);
75
-
76
- for (const workerDir of workerDirs) {
77
- const workerPath = path.join(workersDir, workerDir);
78
- results.push(
79
- updateFile(
80
- path.join(workerPath, 'wrangler.jsonc.example'),
81
- date,
82
- replaceJsoncCompatibilityDate
83
- )
84
- );
85
- results.push(
86
- updateFile(
87
- path.join(workerPath, 'wrangler.jsonc'),
88
- date,
89
- replaceJsoncCompatibilityDate
90
- )
91
- );
92
- }
93
- }
94
-
95
- const updatedCount = results.filter((result) => result.status === 'updated').length;
96
- const unchangedCount = results.filter((result) => result.status === 'unchanged').length;
97
- const missingCount = results.filter((result) => result.status === 'missing').length;
98
-
99
- console.log(`Updated compatibility dates to ${date}`);
100
- console.log(`- Updated: ${updatedCount}`);
101
- console.log(`- Unchanged: ${unchangedCount}`);
102
- console.log(`- Missing: ${missingCount}`);
103
-
104
- for (const result of results) {
105
- if (result.status !== 'updated') {
106
- console.log(` ${result.status.toUpperCase()}: ${path.relative(rootDir, result.filePath)}`);
107
- }
108
- }
109
-
110
- return results;
111
- }
112
-
113
- if (require.main === module) {
114
- const dateArg = process.argv[2] || getCurrentDate();
115
-
116
- try {
117
- updateCompatibilityDates(dateArg);
118
- } catch (error) {
119
- console.error(error.message);
120
- process.exit(1);
121
- }
122
- }
123
-
124
- module.exports = { updateCompatibilityDates };
@@ -1,43 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const packageJson = require('../package.json');
4
-
5
- const markdownFiles = [
6
- '.github/SECURITY.md',
7
- // Add other markdown files that need version updates
8
- ];
9
-
10
- function updateMarkdownVersions() {
11
- console.log(`📝 Updating markdown files with version ${packageJson.version}...`);
12
-
13
- markdownFiles.forEach(filePath => {
14
- const fullPath = path.join(__dirname, '..', filePath);
15
-
16
- if (!fs.existsSync(fullPath)) {
17
- console.log(`⚠️ Skipping ${filePath} (file not found)`);
18
- return;
19
- }
20
-
21
- try {
22
- let content = fs.readFileSync(fullPath, 'utf8');
23
-
24
- // Replace version placeholders
25
- content = content.replace(/{{VERSION}}/g, packageJson.version);
26
- content = content.replace(/v\d+\.\d+\.\d+(-\w+)?/g, `v${packageJson.version}`);
27
-
28
- fs.writeFileSync(fullPath, content);
29
- console.log(`✅ Updated ${filePath}`);
30
- } catch (error) {
31
- console.error(`❌ Error updating ${filePath}:`, error.message);
32
- }
33
- });
34
-
35
- console.log('🎉 Markdown version update complete!');
36
- }
37
-
38
- // Run if called directly
39
- if (require.main === module) {
40
- updateMarkdownVersions();
41
- }
42
-
43
- module.exports = { updateMarkdownVersions };