@striae-org/striae 6.1.8 → 7.0.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.
- package/.env.example +0 -26
- package/app/components/actions/image-manage.ts +17 -67
- package/functions/api/audit/[[path]].ts +9 -24
- package/functions/api/data/[[path]].ts +9 -24
- package/functions/api/image/[[path]].ts +14 -30
- package/functions/api/pdf/[[path]].ts +9 -24
- package/functions/api/user/[[path]].ts +20 -36
- package/package.json +9 -10
- package/scripts/deploy-all.sh +29 -10
- package/scripts/deploy-config/modules/env-utils.sh +0 -68
- package/scripts/deploy-config/modules/prompt.sh +4 -110
- package/scripts/deploy-config/modules/scaffolding.sh +5 -0
- package/scripts/deploy-config/modules/validation.sh +1 -19
- package/scripts/deploy-pages-secrets.sh +0 -9
- package/scripts/deploy-worker-secrets.sh +2 -8
- package/tsconfig.json +1 -4
- package/workers/audit-worker/package.json +2 -2
- package/workers/audit-worker/src/audit-worker.ts +0 -5
- package/workers/audit-worker/src/config.ts +1 -6
- package/workers/audit-worker/src/types.ts +0 -1
- package/workers/audit-worker/wrangler.jsonc.example +2 -6
- package/workers/data-worker/package.json +3 -3
- package/workers/data-worker/src/config.ts +1 -6
- package/workers/data-worker/src/data-worker.ts +1 -6
- package/workers/data-worker/src/types.ts +0 -1
- package/workers/data-worker/wrangler.jsonc.example +2 -4
- package/workers/image-worker/package.json +2 -2
- package/workers/image-worker/src/handlers/delete-image.ts +0 -5
- package/workers/image-worker/src/handlers/mint-signed-url.ts +0 -5
- package/workers/image-worker/src/handlers/serve-image.ts +1 -2
- package/workers/image-worker/src/handlers/upload-image.ts +0 -5
- package/workers/image-worker/src/security/signed-url.ts +2 -2
- package/workers/image-worker/src/types.ts +0 -1
- package/workers/image-worker/wrangler.jsonc.example +2 -1
- package/workers/pdf-worker/package.json +2 -2
- package/workers/pdf-worker/src/pdf-worker.ts +0 -8
- package/workers/pdf-worker/wrangler.jsonc.example +2 -1
- package/workers/user-worker/package.json +2 -2
- package/workers/user-worker/src/auth.ts +0 -7
- package/workers/user-worker/src/types.ts +0 -2
- package/workers/user-worker/src/user-worker.ts +1 -3
- package/workers/user-worker/wrangler.jsonc.example +2 -1
- package/wrangler.toml.example +22 -2
- package/worker-configuration.d.ts +0 -7509
- package/workers/image-worker/src/auth.ts +0 -7
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hasValidToken } from '../auth';
|
|
2
1
|
import {
|
|
3
2
|
normalizeSignedUrlTtlSeconds,
|
|
4
3
|
parseSignedUrlBaseUrl,
|
|
@@ -21,10 +20,6 @@ export async function handleSignedUrlMinting(
|
|
|
21
20
|
fileId: string,
|
|
22
21
|
createJsonResponse: CreateImageWorkerResponse
|
|
23
22
|
): Promise<Response> {
|
|
24
|
-
if (!hasValidToken(request, env)) {
|
|
25
|
-
return createJsonResponse({ error: 'Unauthorized' }, 403);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
requireSignedUrlConfig(env);
|
|
29
24
|
|
|
30
25
|
const existing = await env.STRIAE_FILES.head(fileId);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hasValidToken } from '../auth';
|
|
2
1
|
import {
|
|
3
2
|
decryptBinaryWithRegistry,
|
|
4
3
|
requireEncryptionRetrievalConfig
|
|
@@ -29,7 +28,7 @@ export async function handleImageServing(
|
|
|
29
28
|
if (!tokenValid) {
|
|
30
29
|
return createJsonResponse({ error: 'Invalid or expired signed URL token' }, 403);
|
|
31
30
|
}
|
|
32
|
-
} else
|
|
31
|
+
} else {
|
|
33
32
|
return createJsonResponse({ error: 'Unauthorized' }, 403);
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { hasValidToken } from '../auth';
|
|
2
1
|
import { encryptBinaryForStorage } from '../encryption-utils';
|
|
3
2
|
import { requireEncryptionUploadConfig } from '../security/key-registry';
|
|
4
3
|
import type { CreateImageWorkerResponse, Env } from '../types';
|
|
@@ -9,10 +8,6 @@ export async function handleImageUpload(
|
|
|
9
8
|
env: Env,
|
|
10
9
|
createJsonResponse: CreateImageWorkerResponse
|
|
11
10
|
): Promise<Response> {
|
|
12
|
-
if (!hasValidToken(request, env)) {
|
|
13
|
-
return createJsonResponse({ error: 'Unauthorized' }, 403);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
11
|
requireEncryptionUploadConfig(env);
|
|
17
12
|
|
|
18
13
|
const formData = await request.formData();
|
|
@@ -51,7 +51,7 @@ export function normalizeSignedUrlTtlSeconds(requestedTtlSeconds: unknown, env:
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export function requireSignedUrlConfig(env: Env): void {
|
|
54
|
-
const resolvedSecret = (env.IMAGE_SIGNED_URL_SECRET ||
|
|
54
|
+
const resolvedSecret = (env.IMAGE_SIGNED_URL_SECRET || '').trim();
|
|
55
55
|
if (resolvedSecret.length === 0) {
|
|
56
56
|
throw new Error('Signed URL configuration is missing');
|
|
57
57
|
}
|
|
@@ -77,7 +77,7 @@ export function parseSignedUrlBaseUrl(raw: string): string {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
async function getSignedUrlHmacKey(env: Env): Promise<CryptoKey> {
|
|
80
|
-
const resolvedSecret = (env.IMAGE_SIGNED_URL_SECRET ||
|
|
80
|
+
const resolvedSecret = (env.IMAGE_SIGNED_URL_SECRET || '').trim();
|
|
81
81
|
const keyBytes = new TextEncoder().encode(resolvedSecret);
|
|
82
82
|
|
|
83
83
|
return crypto.subtle.importKey(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"generate:assets": "node scripts/generate-assets.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"start": "wrangler dev"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"wrangler": "^4.84.
|
|
12
|
+
"wrangler": "^4.84.1"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -2,7 +2,6 @@ import type { PDFGenerationData, PDFGenerationRequest, ReportModule, ReportPdfOp
|
|
|
2
2
|
import { getAuditTrailPdfOptions, isAuditTrailReportMode, renderAuditTrailReport } from './audit-trail-report';
|
|
3
3
|
|
|
4
4
|
interface Env {
|
|
5
|
-
PDF_WORKER_AUTH: string;
|
|
6
5
|
ACCOUNT_ID?: string;
|
|
7
6
|
BROWSER_API_TOKEN?: string;
|
|
8
7
|
}
|
|
@@ -40,9 +39,6 @@ const reportModuleLoaders: Record<string, () => Promise<ReportModule>> = {
|
|
|
40
39
|
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
const hasValidHeader = (request: Request, env: Env): boolean =>
|
|
44
|
-
request.headers.get('X-Custom-Auth-Key') === env.PDF_WORKER_AUTH;
|
|
45
|
-
|
|
46
42
|
function isTimeoutError(error: unknown): boolean {
|
|
47
43
|
return error instanceof Error && (
|
|
48
44
|
error.name === 'AbortError' ||
|
|
@@ -193,10 +189,6 @@ async function renderPdfViaRestEndpoint(env: Env, html: string, pdfOptions: Repo
|
|
|
193
189
|
|
|
194
190
|
export default {
|
|
195
191
|
async fetch(request: Request, env: Env): Promise<Response> {
|
|
196
|
-
if (!hasValidHeader(request, env)) {
|
|
197
|
-
return jsonResponse({ error: 'Forbidden' }, 403);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
192
|
if (request.method === 'POST') {
|
|
201
193
|
try {
|
|
202
194
|
const payload = await request.json() as unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "user-worker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"deploy": "wrangler deploy",
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"start": "wrangler dev"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"wrangler": "^4.84.
|
|
11
|
+
"wrangler": "^4.84.1"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { Env } from './types';
|
|
2
2
|
|
|
3
|
-
export async function authenticate(request: Request, env: Env): Promise<void> {
|
|
4
|
-
const authKey = request.headers.get('X-Custom-Auth-Key');
|
|
5
|
-
if (authKey !== env.USER_DB_AUTH) {
|
|
6
|
-
throw new Error('Unauthorized');
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
3
|
export function requireUserKvReadConfig(env: Env): void {
|
|
11
4
|
const hasLegacyPrivateKey = typeof env.USER_KV_ENCRYPTION_PRIVATE_KEY === 'string' && env.USER_KV_ENCRYPTION_PRIVATE_KEY.trim().length > 0;
|
|
12
5
|
const hasRegistryPrivateKeys = typeof env.USER_KV_ENCRYPTION_KEYS_JSON === 'string' && env.USER_KV_ENCRYPTION_KEYS_JSON.trim().length > 0;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export interface Env {
|
|
2
|
-
USER_DB_AUTH: string;
|
|
3
2
|
USER_DB: KVNamespace;
|
|
4
3
|
STRIAE_DATA: R2Bucket;
|
|
5
4
|
STRIAE_FILES: R2Bucket;
|
|
6
|
-
R2_KEY_SECRET: string;
|
|
7
5
|
DATA_AT_REST_ENCRYPTION_PRIVATE_KEY?: string;
|
|
8
6
|
DATA_AT_REST_ENCRYPTION_KEY_ID?: string;
|
|
9
7
|
DATA_AT_REST_ENCRYPTION_KEYS_JSON?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requireUserKvReadConfig, requireUserKvWriteConfig } from './auth';
|
|
2
2
|
import { USER_CASES_SEGMENT } from './config';
|
|
3
3
|
import {
|
|
4
4
|
handleAddCases,
|
|
@@ -20,8 +20,6 @@ function createTextResponse(message: string, status: number): Response {
|
|
|
20
20
|
export default {
|
|
21
21
|
async fetch(request: Request, env: Env): Promise<Response> {
|
|
22
22
|
try {
|
|
23
|
-
await authenticate(request, env);
|
|
24
|
-
|
|
25
23
|
// DELETE can mutate user KV data (for example /:uid/cases), so non-GET methods require write config.
|
|
26
24
|
if (request.method === 'GET') {
|
|
27
25
|
requireUserKvReadConfig(env);
|
package/wrangler.toml.example
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
#:schema node_modules/wrangler/config-schema.json
|
|
2
2
|
name = "PAGES_PROJECT_NAME"
|
|
3
|
-
compatibility_date = "2026-04-
|
|
3
|
+
compatibility_date = "2026-04-21"
|
|
4
4
|
compatibility_flags = ["nodejs_compat"]
|
|
5
5
|
pages_build_output_dir = "./build/client"
|
|
6
6
|
|
|
7
7
|
[placement]
|
|
8
|
-
mode = "smart"
|
|
8
|
+
mode = "smart"
|
|
9
|
+
|
|
10
|
+
[[services]]
|
|
11
|
+
binding = "USER_WORKER"
|
|
12
|
+
service = "USER_WORKER_NAME"
|
|
13
|
+
|
|
14
|
+
[[services]]
|
|
15
|
+
binding = "DATA_WORKER"
|
|
16
|
+
service = "DATA_WORKER_NAME"
|
|
17
|
+
|
|
18
|
+
[[services]]
|
|
19
|
+
binding = "AUDIT_WORKER"
|
|
20
|
+
service = "AUDIT_WORKER_NAME"
|
|
21
|
+
|
|
22
|
+
[[services]]
|
|
23
|
+
binding = "IMAGE_WORKER"
|
|
24
|
+
service = "IMAGES_WORKER_NAME"
|
|
25
|
+
|
|
26
|
+
[[services]]
|
|
27
|
+
binding = "PDF_WORKER"
|
|
28
|
+
service = "PDF_WORKER_NAME"
|