@gaonjs/config 0.10.0 → 0.11.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/dist/wire.js +40 -0
- package/package.json +4 -4
package/dist/wire.js
CHANGED
|
@@ -169,6 +169,8 @@ export async function wireGaon(config, cwd = process.cwd()) {
|
|
|
169
169
|
cookieSecret: config.web?.cookieSecret,
|
|
170
170
|
// 보안 기본값 조정(생략 시 코어 기본값 전부 켬 · CLAUDE.md 규칙 8).
|
|
171
171
|
security: config.web?.security,
|
|
172
|
+
// 결정 131: 스토리지 오리진 CSP 자동 배선(설정 있으면 img-src·connect-src 에 부착).
|
|
173
|
+
storageOrigins: storageCspOrigins(config.storage),
|
|
172
174
|
// 클라이언트 IP 정책(결정 120 · 생략 시 'direct'). 프록시 뒤 배치면 선언.
|
|
173
175
|
clientIp: config.web?.clientIp,
|
|
174
176
|
realtime: nats ? { nats, hubAddr: config.hub?.addr, heartbeatMs: config.hub?.heartbeatMs } : undefined,
|
|
@@ -197,3 +199,41 @@ export async function wireGaon(config, cwd = process.cwd()) {
|
|
|
197
199
|
}
|
|
198
200
|
// redisSessionStore 는 참조만 유지(트리 셰이킹 방지 · 향후 캐시 재사용).
|
|
199
201
|
void redisSessionStore;
|
|
202
|
+
/**
|
|
203
|
+
* 결정 131: storage 설정에서 CSP 오리진을 계산한다(s3 드라이버만). endpoint = 브라우저 직접
|
|
204
|
+
* presigned PUT/GET 오리진(connect-src) 겸 presigned 표시 폴백(img-src). publicUrl = 공개/CDN
|
|
205
|
+
* 표시 오리진(img-src). 로컬 디스크는 same-origin 상대 URL 이라 CSP 와 무관(제외). 오리진은
|
|
206
|
+
* `new URL(v).origin`(scheme+host+port) 만 — 경로·쿼리는 배제한다.
|
|
207
|
+
*/
|
|
208
|
+
function storageCspOrigins(storage) {
|
|
209
|
+
if (!storage)
|
|
210
|
+
return undefined;
|
|
211
|
+
const img = new Set();
|
|
212
|
+
const connect = new Set();
|
|
213
|
+
for (const [name, d] of Object.entries(storage.disks)) {
|
|
214
|
+
if (d.driver !== 's3')
|
|
215
|
+
continue; // 로컬 디스크(상대 baseUrl)는 same-origin — CSP 불필요
|
|
216
|
+
if (d.endpoint) {
|
|
217
|
+
const origin = parseStorageOrigin(d.endpoint, `storage.disks.${name}.endpoint`);
|
|
218
|
+
connect.add(origin);
|
|
219
|
+
img.add(origin);
|
|
220
|
+
}
|
|
221
|
+
if (d.publicUrl) {
|
|
222
|
+
img.add(parseStorageOrigin(d.publicUrl, `storage.disks.${name}.publicUrl`));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (img.size === 0 && connect.size === 0)
|
|
226
|
+
return undefined;
|
|
227
|
+
return { img: [...img], connect: [...connect] };
|
|
228
|
+
}
|
|
229
|
+
/** 절대 URL 의 오리진(scheme+host+port)만 뽑는다. 비절대 URL 은 부팅 에러(수리 안내 · §7.5.3). */
|
|
230
|
+
function parseStorageOrigin(value, where) {
|
|
231
|
+
try {
|
|
232
|
+
return new URL(value).origin;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
throw new Error(`[@gaonjs/config] ${where} = ${JSON.stringify(value)} 가 절대 URL 이 아닙니다(CSP 오리진 계산 불가).\n` +
|
|
236
|
+
` → gaon.config.ts 의 storage 설정에서 scheme+host 를 갖춘 절대 URL 로 지정하세요` +
|
|
237
|
+
` (예: 'https://cdn.example.com' · 'http://127.0.0.1:9000').`);
|
|
238
|
+
}
|
|
239
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaonjs/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Gaon 루트 설정 로더·자동 배선 (gaon.config.ts · §3.3 · M9-A)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ioredis": "^5.4.1",
|
|
28
28
|
"@gaonjs/async": "0.8.0",
|
|
29
|
-
"@gaonjs/i18n": "0.1.2",
|
|
30
29
|
"@gaonjs/data": "0.13.1",
|
|
31
|
-
"@gaonjs/mail": "0.1.3",
|
|
32
30
|
"@gaonjs/core": "0.2.1",
|
|
33
31
|
"@gaonjs/storage": "0.1.2",
|
|
34
|
-
"@gaonjs/
|
|
32
|
+
"@gaonjs/mail": "0.1.3",
|
|
33
|
+
"@gaonjs/web": "0.14.0",
|
|
34
|
+
"@gaonjs/i18n": "0.1.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"fastify": "^5.0.0"
|