resuxjs 0.4.0-beta.7 → 0.4.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/README.md +4 -2
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/build/index.d.ts +1 -2
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +125 -31
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +2 -3
- package/dist/compiler/adapter.js +2 -2
- package/dist/compiler/dev-warnings.d.ts +1 -2
- package/dist/compiler/directives.d.ts +1 -2
- package/dist/compiler/directives.js +7 -3
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +4 -2
- package/dist/compiler/implementation.js +101 -43
- package/dist/compiler/index.d.ts +2 -3
- package/dist/compiler/index.js +2 -2
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +1 -2
- package/dist/core/hooks.d.ts +10 -2
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/module-container.d.ts +1 -2
- package/dist/core/module-container.js +2 -1
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +1 -2
- package/dist/create.d.ts +1 -2
- package/dist/create.js +110 -33
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +1 -2
- package/dist/deploy/common.d.ts +1 -2
- package/dist/deploy/common.js +19 -3
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +1 -2
- package/dist/deploy/index.d.ts +1 -2
- package/dist/deploy/netlify.d.ts +1 -2
- package/dist/deploy/node.d.ts +1 -2
- package/dist/deploy/production-report.d.ts +1 -2
- package/dist/deploy/runtime-dependencies.d.ts +1 -2
- package/dist/deploy/static.d.ts +1 -2
- package/dist/deploy/types.d.ts +1 -2
- package/dist/deploy/vercel.d.ts +1 -2
- package/dist/deploy/vercel.js +3 -3
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +1 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +1 -2
- package/dist/halal-core/ai/classifyProject.d.ts +1 -2
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +1 -2
- package/dist/halal-core/ai/createProjectSummary.d.ts +1 -2
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -2
- package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -2
- package/dist/halal-core/ai/validateAiResponse.d.ts +1 -2
- package/dist/halal-core/cli/check.d.ts +1 -2
- package/dist/halal-core/cli/explain.d.ts +1 -2
- package/dist/halal-core/cli/report.d.ts +1 -2
- package/dist/halal-core/cli/submitReview.d.ts +1 -2
- package/dist/halal-core/cli/verifyReview.d.ts +1 -2
- package/dist/halal-core/config.d.ts +2 -2
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +1 -2
- package/dist/halal-core/crypto/integrity.js +1 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +4 -3
- package/dist/halal-core/enforce.js +31 -4
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/lifecycle.d.ts +1 -2
- package/dist/halal-core/policy.d.ts +1 -2
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +1 -2
- package/dist/halal-core/report/formatTerminalReport.d.ts +1 -2
- package/dist/halal-core/report/generateHalalReport.d.ts +1 -2
- package/dist/halal-core/report/signReport.d.ts +1 -2
- package/dist/halal-core/report/verifyReport.d.ts +1 -2
- package/dist/halal-core/review/createReviewRequest.d.ts +1 -2
- package/dist/halal-core/review/reviewPolicy.d.ts +1 -2
- package/dist/halal-core/review/signedReviewFile.d.ts +1 -2
- package/dist/halal-core/review/verifyReviewApproval.d.ts +1 -2
- package/dist/halal-core/rules/adultContentRules.d.ts +1 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +1 -2
- package/dist/halal-core/rules/childSafetyRules.d.ts +1 -2
- package/dist/halal-core/rules/coreCategories.d.ts +1 -2
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +1 -2
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +1 -2
- package/dist/halal-core/rules/dependencyRules.d.ts +1 -2
- package/dist/halal-core/rules/endpointRules.d.ts +1 -2
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/financeRibaRules.d.ts +1 -2
- package/dist/halal-core/rules/gamblingRules.d.ts +1 -2
- package/dist/halal-core/rules/generalHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/healthHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/keywordRules.d.ts +1 -2
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +1 -2
- package/dist/halal-core/rules/scamFraudRules.d.ts +1 -2
- package/dist/halal-core/rules/selfHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +1 -2
- package/dist/halal-core/runtime/guard.d.ts +1 -2
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +1 -2
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +1 -2
- package/dist/halal-core/runtime/types.d.ts +1 -2
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -2
- package/dist/halal-core/scanner/scanComponents.d.ts +1 -2
- package/dist/halal-core/scanner/scanContent.d.ts +1 -2
- package/dist/halal-core/scanner/scanDependencies.d.ts +1 -2
- package/dist/halal-core/scanner/scanDomains.d.ts +1 -2
- package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -2
- package/dist/halal-core/scanner/scanMetadata.d.ts +1 -2
- package/dist/halal-core/scanner/scanPages.d.ts +1 -2
- package/dist/halal-core/scanner/scanProject.d.ts +1 -2
- package/dist/halal-core/scanner/scanRoutes.d.ts +1 -2
- package/dist/halal-core/scanner/scanTranslations.d.ts +1 -2
- package/dist/halal-core/status.d.ts +1 -2
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -2
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -2
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +1 -2
- package/dist/head/utils.d.ts +15 -0
- package/dist/head/utils.js +52 -0
- package/dist/head/utils.js.map +1 -0
- package/dist/i18n/index.d.ts +1 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +1 -2
- package/dist/icons/api-fetcher.d.ts +1 -2
- package/dist/icons/cache.d.ts +1 -2
- package/dist/icons/cache.js.map +1 -1
- package/dist/icons/component.d.ts +7 -8
- package/dist/icons/constants.d.ts +1 -2
- package/dist/icons/css-mode.d.ts +1 -2
- package/dist/icons/index.d.ts +1 -2
- package/dist/icons/index.js.map +1 -1
- package/dist/icons/local-svg.d.ts +1 -2
- package/dist/icons/normalize.d.ts +1 -2
- package/dist/icons/offline-loader.d.ts +1 -2
- package/dist/icons/parser.d.ts +1 -2
- package/dist/icons/registry.d.ts +1 -2
- package/dist/icons/resolver.d.ts +1 -2
- package/dist/icons/svg-mode.d.ts +1 -2
- package/dist/icons/transform.d.ts +1 -2
- package/dist/icons/types.d.ts +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kit/index.d.ts +1 -2
- package/dist/nitro-server/index.d.ts +1 -2
- package/dist/node.d.ts +1 -2
- package/dist/reactivity/computed.d.ts +1 -2
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +3 -3
- package/dist/reactivity/effect.js +8 -3
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/reactive.d.ts +1 -2
- package/dist/reactivity/reactive.js +221 -11
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/ref.d.ts +1 -2
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +1 -2
- package/dist/reactivity/scheduler.js +2 -0
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +1 -2
- package/dist/reactivity/utils.d.ts +1 -2
- package/dist/reactivity/watch.d.ts +1 -2
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +1 -2
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +19 -2
- package/dist/runtime/index.js +921 -170
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/resume.d.ts +1 -2
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +1 -2
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +1 -2
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/runtime/view-transitions/detect.d.ts +1 -2
- package/dist/runtime/view-transitions/transition.d.ts +1 -2
- package/dist/runtime/view-transitions/types.d.ts +1 -2
- package/dist/security/media-fetch.d.ts +1 -2
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +1 -2
- package/dist/security/path-boundary.js +10 -4
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +41 -42
- package/dist/ui/verification-code.d.ts +9 -10
- package/dist/ui/verification-code.js.map +1 -1
- package/dist/vite-builder/index.d.ts +1 -2
- package/package.json +2 -2
- package/templates/default/.env.example +3 -0
- package/templates/default/nitro.config.ts +16 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce.js","names":[],"sources":["../../src/halal-core/enforce.ts"],"sourcesContent":["import { scanProject } from \"./scanner/scanProject.js\";\nimport { evaluateRules } from \"./rules/defaultBlockedRules.js\";\nimport { loadProjectPolicy } from \"./config.js\";\nimport { formatTerminalReport } from \"./report/formatTerminalReport.js\";\nimport { generateHalalReport } from \"./report/generateHalalReport.js\";\nimport { createReviewEvidenceHash } from \"./review/signedReviewFile.js\";\nimport { verifyReviewApproval } from \"./review/verifyReviewApproval.js\";\nimport { checkOnDiskReportSignature } from \"./tamper/verifyReportSignature.js\";\nimport { verifyCoreIntegrity } from \"./tamper/verifyCoreIntegrity.js\";\n\nexport async function enforceDevGuard(appRoot: string, outDir: string): Promise<void> {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n if (!verifyCoreIntegrity(appRoot)) {\n console.error(\"[resux-halal-core] Framework integrity compromised.\");\n process.exit(1);\n }\n\n const policy = await loadProjectPolicy(appRoot);\n const scanned = scanProject(appRoot);\n const report = evaluateRules(scanned, policy);\n\n const isStrict = policy.halalAI?.strict === true;\n\n if (report.status === \"review_required\") {\n const checkReview = verifyReviewApproval(appRoot, report.status, {\n projectName: policy.projectName,\n evidenceHash: createReviewEvidenceHash(report),\n });\n if (!checkReview.approved) {\n console.error(formatTerminalReport(report));\n console.error(`\\x1b[31m[resux-halal-core] Cannot start dev server: ${checkReview.reason}\\x1b[0m`);\n process.exit(1);\n }\n } else if (report.status === \"blocked\") {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Cannot start dev server: Project violates safety policy.\\x1b[0m\");\n process.exit(1);\n } else if (report.status === \"warning\") {\n console.warn(formatTerminalReport(report));\n if (isStrict) {\n console.error(\"\\x1b[31m[resux-halal-core] Dev startup blocked: Strict mode enabled and warnings found.\\x1b[0m\");\n process.exit(1);\n }\n }\n}\n\nexport async function enforceBuildGuard(appRoot: string, outDir: string): Promise<void> {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n if (!verifyCoreIntegrity(appRoot)) {\n console.error(\"[resux-halal-core] Framework integrity compromised.\");\n process.exit(1);\n }\n\n const policy = await loadProjectPolicy(appRoot);\n const scanned = scanProject(appRoot);\n const report = generateHalalReport(scanned, policy, outDir, {\n requireAuthenticated: true,\n });\n\n const blockProductionBuild = policy.halalAI?.blockProductionBuild !== false;\n const isStrict = policy.halalAI?.strict === true;\n\n if (report.status === \"review_required\") {\n const checkReview = verifyReviewApproval(appRoot, report.status, {\n projectName: policy.projectName,\n evidenceHash: createReviewEvidenceHash(report),\n });\n if (!checkReview.approved) {\n console.error(formatTerminalReport(report));\n console.error(`\\x1b[31m[resux-halal-core] Build failed: ${checkReview.reason}\\x1b[0m`);\n process.exit(1);\n }\n } else if (report.status === \"blocked\") {\n if (blockProductionBuild) {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Build failed: Project violates safety policy.\\x1b[0m\");\n process.exit(1);\n } else {\n console.warn(formatTerminalReport(report));\n console.warn(\"\\x1b[33m[resux-halal-core] Warning: build-time safety violations found, proceeding due to blockProductionBuild = false.\\x1b[0m\");\n }\n } else if (report.status === \"warning\" && isStrict) {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Build failed: Strict mode enabled and warnings found.\\x1b[0m\");\n process.exit(1);\n }\n}\n\nexport function enforcePreviewGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir);\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Preview rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n\nexport function enforceProductionServerGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Production server startup rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n\nexport function enforceDeploymentGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Deployment rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,eAAsB,gBAAgB,SAAiB,QAA+B;CACpF,IAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,QACjD;CAGF,IAAI,CAAC,oBAAoB,OAAO,GAAG;EACjC,QAAQ,MAAM,qDAAqD;EACn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,CAAC;CAC/E,IAAI,CAAC,MAAM,OAAO;EAChB,QAAQ,MAAM,mDAAmD,MAAM,OAAO,QAAQ;EACtF,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"enforce.js","names":[],"sources":["../../src/halal-core/enforce.ts"],"sourcesContent":["import { scanProject } from \"./scanner/scanProject.js\";\nimport { evaluateRules } from \"./rules/defaultBlockedRules.js\";\nimport { loadProjectPolicy } from \"./config.js\";\nimport { formatTerminalReport } from \"./report/formatTerminalReport.js\";\nimport { generateHalalReport } from \"./report/generateHalalReport.js\";\nimport { createReviewEvidenceHash } from \"./review/signedReviewFile.js\";\nimport { verifyReviewApproval } from \"./review/verifyReviewApproval.js\";\nimport { checkOnDiskReportSignature } from \"./tamper/verifyReportSignature.js\";\nimport { randomBytes } from \"node:crypto\";\nimport { verifyCoreIntegrity } from \"./tamper/verifyCoreIntegrity.js\";\n\nexport async function enforceDevGuard(appRoot: string, outDir: string): Promise<void> {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n if (!verifyCoreIntegrity(appRoot)) {\n console.error(\"[resux-halal-core] Framework integrity compromised.\");\n process.exit(1);\n }\n\n const policy = await loadProjectPolicy(appRoot);\n const scanned = scanProject(appRoot);\n const report = evaluateRules(scanned, policy);\n\n const isStrict = policy.halalAI?.strict === true;\n\n if (report.status === \"review_required\") {\n const checkReview = verifyReviewApproval(appRoot, report.status, {\n projectName: policy.projectName,\n evidenceHash: createReviewEvidenceHash(report),\n });\n if (!checkReview.approved) {\n console.error(formatTerminalReport(report));\n console.error(`\\x1b[31m[resux-halal-core] Cannot start dev server: ${checkReview.reason}\\x1b[0m`);\n process.exit(1);\n }\n } else if (report.status === \"blocked\") {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Cannot start dev server: Project violates safety policy.\\x1b[0m\");\n process.exit(1);\n } else if (report.status === \"warning\") {\n console.warn(formatTerminalReport(report));\n if (isStrict) {\n console.error(\"\\x1b[31m[resux-halal-core] Dev startup blocked: Strict mode enabled and warnings found.\\x1b[0m\");\n process.exit(1);\n }\n }\n}\n\nexport async function enforceBuildGuard(\n appRoot: string,\n outDir: string,\n options: { ignoreTestEnv?: boolean } = {}\n): Promise<void> {\n if ((process.env.VITEST || process.env.NODE_ENV === \"test\") && !options.ignoreTestEnv) {\n return;\n }\n\n if (!verifyCoreIntegrity(appRoot)) {\n console.error(\"[resux-halal-core] Framework integrity compromised.\");\n process.exit(1);\n }\n\n const policy = await loadProjectPolicy(appRoot);\n const scanned = scanProject(appRoot);\n\n const requireAuthenticated = policy.halalAI?.requireAuthenticated === true || process.env.RESUX_HALAL_REPORT_REQUIRE_AUTHENTICATED === \"true\";\n let signingSecret: string | undefined = process.env.RESUX_HALAL_REPORT_SIGNING_SECRET;\n // A configured secret means the deployment expects authenticated reports:\n // the production server guard requires a valid authenticated signature\n // whenever a signing secret is present, so the build must sign with it.\n let requireAuth = requireAuthenticated || Boolean(signingSecret);\n\n if (!signingSecret) {\n if (requireAuthenticated) {\n console.error(\n \"[resux-halal-core] Build failed: RESUX_HALAL_REPORT_SIGNING_SECRET must be configured with at least 32 characters when Halal report authentication is enabled (policy.halalAI.requireAuthenticated = true). Configure it in your .env or environment variables. See https://resux.dev/getting-started for details.\"\n );\n process.exit(1);\n } else {\n const ephemeralSecret = randomBytes(32).toString(\"hex\");\n signingSecret = ephemeralSecret;\n process.env.RESUX_HALAL_REPORT_SIGNING_SECRET = ephemeralSecret;\n console.warn(\n \"\\x1b[33m[resux-halal-core] Warning: RESUX_HALAL_REPORT_SIGNING_SECRET is not configured. Generated an ephemeral signing secret for this build. For production deployments requiring authenticated Halal reports, configure RESUX_HALAL_REPORT_SIGNING_SECRET (at least 32 characters) in your environment or .env file.\\x1b[0m\"\n );\n requireAuth = true;\n }\n }\n\n const report = generateHalalReport(scanned, policy, outDir, {\n requireAuthenticated: requireAuth,\n signingSecret,\n });\n\n const blockProductionBuild = policy.halalAI?.blockProductionBuild !== false;\n const isStrict = policy.halalAI?.strict === true;\n\n if (report.status === \"review_required\") {\n const checkReview = verifyReviewApproval(appRoot, report.status, {\n projectName: policy.projectName,\n evidenceHash: createReviewEvidenceHash(report),\n });\n if (!checkReview.approved) {\n console.error(formatTerminalReport(report));\n console.error(`\\x1b[31m[resux-halal-core] Build failed: ${checkReview.reason}\\x1b[0m`);\n process.exit(1);\n }\n } else if (report.status === \"blocked\") {\n if (blockProductionBuild) {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Build failed: Project violates safety policy.\\x1b[0m\");\n process.exit(1);\n } else {\n console.warn(formatTerminalReport(report));\n console.warn(\"\\x1b[33m[resux-halal-core] Warning: build-time safety violations found, proceeding due to blockProductionBuild = false.\\x1b[0m\");\n }\n } else if (report.status === \"warning\" && isStrict) {\n console.error(formatTerminalReport(report));\n console.error(\"\\x1b[31m[resux-halal-core] Build failed: Strict mode enabled and warnings found.\\x1b[0m\");\n process.exit(1);\n }\n}\n\nexport function enforcePreviewGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir);\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Preview rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n\nexport function enforceProductionServerGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const requireAuthenticated = process.env.RESUX_HALAL_REPORT_REQUIRE_AUTHENTICATED === \"true\" || Boolean(process.env.RESUX_HALAL_REPORT_SIGNING_SECRET);\n const check = checkOnDiskReportSignature(outDir, {\n requireAuthenticated,\n secret: process.env.RESUX_HALAL_REPORT_SIGNING_SECRET,\n });\n if (!check.valid) {\n if (!requireAuthenticated) {\n console.warn(\"\\x1b[33m[resux-halal-core] Warning: Starting server without authenticated Halal report signature.\\x1b[0m\");\n return;\n }\n console.error(`\\x1b[31m[resux-halal-core] Production server startup rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n\nexport function enforceDeploymentGuard(outDir: string): void {\n if (process.env.VITEST || process.env.NODE_ENV === \"test\") {\n return;\n }\n\n const check = checkOnDiskReportSignature(outDir, { requireAuthenticated: true });\n if (!check.valid) {\n console.error(`\\x1b[31m[resux-halal-core] Deployment rejected: ${check.reason}\\x1b[0m`);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,eAAsB,gBAAgB,SAAiB,QAA+B;CACpF,IAAI,QAAQ,IAAI,UAAU,QAAQ,IAAI,aAAa,QACjD;CAGF,IAAI,CAAC,oBAAoB,OAAO,GAAG;EACjC,QAAQ,MAAM,qDAAqD;EACnE,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,SAAS,MAAM,kBAAkB,OAAO;CAC9C,MAAM,UAAU,YAAY,OAAO;CACnC,MAAM,SAAS,cAAc,SAAS,MAAM;CAE5C,MAAM,WAAW,OAAO,SAAS,WAAW;CAE5C,IAAI,OAAO,WAAW,mBAAmB;EACvC,MAAM,cAAc,qBAAqB,SAAS,OAAO,QAAQ;GAC/D,aAAa,OAAO;GACpB,cAAc,yBAAyB,MAAM;EAC/C,CAAC;EACD,IAAI,CAAC,YAAY,UAAU;GACzB,QAAQ,MAAM,qBAAqB,MAAM,CAAC;GAC1C,QAAQ,MAAM,uDAAuD,YAAY,OAAO,QAAQ;GAChG,QAAQ,KAAK,CAAC;EAChB;CACF,OAAO,IAAI,OAAO,WAAW,WAAW;EACtC,QAAQ,MAAM,qBAAqB,MAAM,CAAC;EAC1C,QAAQ,MAAM,4FAA4F;EAC1G,QAAQ,KAAK,CAAC;CAChB,OAAO,IAAI,OAAO,WAAW,WAAW;EACtC,QAAQ,KAAK,qBAAqB,MAAM,CAAC;EACzC,IAAI,UAAU;GACZ,QAAQ,MAAM,gGAAgG;GAC9G,QAAQ,KAAK,CAAC;EAChB;CACF;AACF;AAEA,eAAsB,kBACpB,SACA,QACA,UAAuC,CA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void;
|
|
2
|
-
//# sourceMappingURL=lifecycle.d.ts.map
|
|
1
|
+
export declare function registerHalalCoreHooks(hooks: any, appRoot: string, outDir: string): void;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { ResuxHalalPolicy } from "./config.js";
|
|
2
|
-
export declare function defineResuxHalalPolicy(config: ResuxHalalPolicy): ResuxHalalPolicy;
|
|
3
|
-
//# sourceMappingURL=policy.d.ts.map
|
|
2
|
+
export declare function defineResuxHalalPolicy(config: ResuxHalalPolicy): ResuxHalalPolicy;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
|
-
export declare function formatBrowserOverlayScript(report: HalalCheckResult): string;
|
|
3
|
-
//# sourceMappingURL=formatBrowserOverlay.d.ts.map
|
|
2
|
+
export declare function formatBrowserOverlayScript(report: HalalCheckResult): string;
|
|
@@ -4,5 +4,4 @@ export interface GenerateHalalReportOptions {
|
|
|
4
4
|
requireAuthenticated?: boolean;
|
|
5
5
|
signingSecret?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function generateHalalReport(scannedData: any, policy: ResuxHalalPolicy, outDir: string, options?: GenerateHalalReportOptions): HalalCheckResult;
|
|
8
|
-
//# sourceMappingURL=generateHalalReport.d.ts.map
|
|
7
|
+
export declare function generateHalalReport(scannedData: any, policy: ResuxHalalPolicy, outDir: string, options?: GenerateHalalReportOptions): HalalCheckResult;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { HalalCheckResult } from "../status.js";
|
|
2
2
|
export declare function generateReportSignature(report: Omit<HalalCheckResult, "signature">, secret?: string): string;
|
|
3
|
-
export declare function generateReportChecksum(report: Omit<HalalCheckResult, "signature">): string;
|
|
4
|
-
//# sourceMappingURL=signReport.d.ts.map
|
|
3
|
+
export declare function generateReportChecksum(report: Omit<HalalCheckResult, "signature">): string;
|
|
@@ -8,5 +8,4 @@ export declare function verifyReportSignature(report: HalalCheckResult, options?
|
|
|
8
8
|
export declare function isReportValid(report: HalalCheckResult, options?: ReportVerificationOptions): {
|
|
9
9
|
valid: boolean;
|
|
10
10
|
reason?: string;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=verifyReport.d.ts.map
|
|
11
|
+
};
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { ResuxHalalPolicy } from "../config.js";
|
|
2
|
-
export declare function createReviewRequest(appRoot: string, policy: ResuxHalalPolicy, outDir: string): string;
|
|
3
|
-
//# sourceMappingURL=createReviewRequest.d.ts.map
|
|
2
|
+
export declare function createReviewRequest(appRoot: string, policy: ResuxHalalPolicy, outDir: string): string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const REVIEWABLE_CATEGORIES: string[];
|
|
2
2
|
export declare const NON_REVIEWABLE_CATEGORIES: string[];
|
|
3
|
-
export declare function isCategoryReviewable(category: string): boolean;
|
|
4
|
-
//# sourceMappingURL=reviewPolicy.d.ts.map
|
|
3
|
+
export declare function isCategoryReviewable(category: string): boolean;
|
|
@@ -10,5 +10,4 @@ export interface SignedReviewApproval {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function generateReviewSignature(approval: Omit<SignedReviewApproval, "signature">, secret?: string): string;
|
|
12
12
|
export declare function verifyReviewSignature(approval: SignedReviewApproval, secret?: string): boolean;
|
|
13
|
-
export declare function createReviewEvidenceHash(report: HalalCheckResult | Omit<HalalCheckResult, "signature">): string;
|
|
14
|
-
//# sourceMappingURL=signedReviewFile.d.ts.map
|
|
13
|
+
export declare function createReviewEvidenceHash(report: HalalCheckResult | Omit<HalalCheckResult, "signature">): string;
|
|
@@ -7,5 +7,4 @@ export interface ReviewApprovalVerificationOptions {
|
|
|
7
7
|
export declare function verifyReviewApproval(appRoot: string, currentStatus: string, options?: ReviewApprovalVerificationOptions): {
|
|
8
8
|
approved: boolean;
|
|
9
9
|
reason?: string;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=verifyReviewApproval.d.ts.map
|
|
10
|
+
};
|
|
@@ -16,5 +16,4 @@ export declare function createHalalRuntimeGuard(options?: HalalRuntimeGuardOptio
|
|
|
16
16
|
}[];
|
|
17
17
|
}>;
|
|
18
18
|
};
|
|
19
|
-
export declare function evaluateHalalRuntimeContent(content: HalalRuntimeContent, options?: HalalRuntimeGuardOptions): Promise<HalalRuntimeDecision>;
|
|
20
|
-
//# sourceMappingURL=guard.d.ts.map
|
|
19
|
+
export declare function evaluateHalalRuntimeContent(content: HalalRuntimeContent, options?: HalalRuntimeGuardOptions): Promise<HalalRuntimeDecision>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","names":[],"sources":["../../../src/halal-core/runtime/guard.ts"],"sourcesContent":["import { classifyRuntimeContentWithAi } from \"../ai/classifyRuntimeContent.js\";\nimport { evaluateRules } from \"../rules/defaultBlockedRules.js\";\nimport { scanDomains } from \"../scanner/scanDomains.js\";\nimport type { HalalCheckResult, HalalGuardStatus } from \"../status.js\";\nimport {\n createRuntimeContentFingerprint,\n findReviewedRuntimeDecision,\n} from \"./reviewedMemory.js\";\nimport {\n prepareRuntimeContent,\n type RuntimeContentInspectionIssue,\n} from \"./serializeRuntimeContent.js\";\nimport type {\n HalalRuntimeContent,\n HalalRuntimeDecision,\n HalalRuntimeGuardOptions,\n} from \"./types.js\";\n\nconst STATUS_RANK: Record<HalalGuardStatus, number> = {\n allowed: 0,\n warning: 1,\n review_required: 2,\n blocked: 3,\n};\n\nconst RISK_RANK: Record<HalalCheckResult[\"riskLevel\"], number> = {\n low: 0,\n medium: 1,\n high: 2,\n critical: 3,\n};\n\nexport class HalalRuntimeBlockedError extends Error {\n readonly decision: HalalRuntimeDecision;\n\n constructor(decision: HalalRuntimeDecision) {\n super(decision.reasons[0] || \"Runtime content was rejected by the halal guard.\");\n this.name = \"HalalRuntimeBlockedError\";\n this.decision = decision;\n }\n}\n\nexport function createHalalRuntimeGuard(options: HalalRuntimeGuardOptions = {}) {\n return {\n check(content: HalalRuntimeContent): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent(content, options);\n },\n\n checkDynamicPage(content: Omit<HalalRuntimeContent, \"kind\">): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent({ ...content, kind: \"dynamic_page\" }, options);\n },\n\n checkAd(content: Omit<HalalRuntimeContent, \"kind\">): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent({ ...content, kind: \"advertisement\" }, options);\n },\n\n async assertAllowed(content: HalalRuntimeContent): Promise<HalalRuntimeDecision> {\n const decision = await evaluateHalalRuntimeContent(content, options);\n if (!decision.allowed) {\n throw new HalalRuntimeBlockedError(decision);\n }\n return decision;\n },\n\n async filterAds<T extends Omit<HalalRuntimeContent, \"kind\">>(ads: readonly T[]) {\n const checked = await Promise.all(ads.map(async (ad) => ({\n ad,\n decision: await evaluateHalalRuntimeContent({ ...ad, kind: \"advertisement\" }, options),\n })));\n return {\n allowed: checked.filter((entry) => entry.decision.allowed).map((entry) => entry.ad),\n rejected: checked.filter((entry) => !entry.decision.allowed),\n };\n },\n };\n}\n\nexport async function evaluateHalalRuntimeContent(\n content: HalalRuntimeContent,\n options: HalalRuntimeGuardOptions = {},\n): Promise<HalalRuntimeDecision> {\n const serialized = prepareRuntimeContent(content, options.maxContentCharacters);\n const fingerprint = createRuntimeContentFingerprint(content);\n const file = `runtime:${content.kind}:${content.id || content.route || \"anonymous\"}`;\n const scannedResult = evaluateRules({\n routes: content.route ? [content.route] : [],\n pages: content.kind === \"dynamic_page\" && content.route ? [content.route] : [],\n components: [],\n metadata: {\n title: content.title,\n description: content.advertiser\n ? `Advertiser: ${content.advertiser}`\n : `${content.kind} runtime content`,\n },\n envNames: [],\n dependencies: {},\n i18nWords: [],\n contentTexts: [{ file, text: serialized.localText }],\n endpoints: scanDomains([{ file, text: serialized.localText }]),\n }, options.policy ?? {});\n\n let localResult = scannedResult;\n if (serialized.truncated) {\n localResult = mergeResults(\n localResult,\n truncatedContentResult(file, serialized.maxCharacters),\n );\n }\n if (serialized.inspectionIssues.length > 0) {\n localResult = mergeResults(\n localResult,\n uninspectableContentResult(file, serialized.inspectionIssues),\n );\n }\n\n const reviewed = findReviewedRuntimeDecision(\n content,\n options.reviewedDecisions,\n options.reviewSecret,\n );\n if (reviewed) {\n const reviewedResult = decisionFromReviewedMemory(content, fingerprint, reviewed, options.strict === true);\n if (STATUS_RANK[reviewedResult.status] >= STATUS_RANK[localResult.status]\n || STATUS_RANK[localResult.status] <= STATUS_RANK.warning) {\n return reviewedResult;\n }\n }\n\n if (localResult.status === \"blocked\") {\n return finalizeDecision(content, fingerprint, localResult, \"local_rules\", options.strict === true);\n }\n\n const aiResult = await classifyRuntimeContentWithAi(\n content,\n serialized.aiText,\n localResult,\n options.ai,\n );\n const requiresAi = content.kind === \"advertisement\"\n ? options.ai?.requireForAds !== false\n : options.ai?.requireForDynamicContent === true;\n\n if (!aiResult && requiresAi) {\n const unverified = mergeResults(localResult, {\n status: \"review_required\",\n riskLevel: \"medium\",\n categories: [content.kind === \"advertisement\" ? \"unverified_ad\" : \"unverified_dynamic_content\"],\n confidence: 0,\n reasons: [\"Required runtime AI verification is not configured or unavailable.\"],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Do not render this content until AI verification or signed human review is available.\",\n });\n return finalizeDecision(content, fingerprint, unverified, \"local_rules\", options.strict === true);\n }\n\n const result = aiResult ? mergeResults(localResult, aiResult) : localResult;\n return finalizeDecision(\n content,\n fingerprint,\n result,\n aiResult ? \"local_and_ai\" : \"local_rules\",\n options.strict === true,\n );\n}\n\nfunction truncatedContentResult(file: string, maxCharacters: number): HalalCheckResult {\n return {\n status: \"review_required\",\n riskLevel: \"medium\",\n categories: [\"runtime_content_truncated\"],\n confidence: 1,\n reasons: [\n `Runtime content exceeded the ${maxCharacters}-character scan limit and was not fully inspected.`,\n ],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Increase maxContentCharacters or complete a manual review before rendering.\",\n };\n}\n\nfunction uninspectableContentResult(\n file: string,\n issues: readonly RuntimeContentInspectionIssue[],\n): HalalCheckResult {\n const issueDescriptions = issues.map((issue) => {\n if (issue === \"max_depth\") return \"maximum serialization depth was reached\";\n if (issue === \"unreadable_property\") return \"one or more properties could not be read\";\n return \"one or more objects could not be inspected\";\n });\n\n return {\n status: \"review_required\",\n riskLevel: \"high\",\n categories: [\"runtime_content_uninspectable\"],\n confidence: 1,\n reasons: [\n `Runtime content could not be fully inspected: ${uniqueStrings(issueDescriptions).join(\"; \")}.`,\n ],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Normalize runtime content to plain inspectable data or complete a manual review before rendering.\",\n };\n}\n\nfunction decisionFromReviewedMemory(\n content: HalalRuntimeContent,\n fingerprint: string,\n reviewed: NonNullable<HalalRuntimeGuardOptions[\"reviewedDecisions\"]>[number],\n strict: boolean,\n): HalalRuntimeDecision {\n const result: HalalCheckResult = {\n status: reviewed.status,\n riskLevel: reviewed.status === \"blocked\"\n ? \"high\"\n : reviewed.status === \"review_required\"\n ? \"medium\"\n : reviewed.status === \"warning\"\n ? \"medium\"\n : \"low\",\n categories: reviewed.categories,\n confidence: 1,\n reasons: [`Signed review by ${reviewed.reviewerId}: ${reviewed.reason}`],\n matchedFiles: [],\n matchedSnippets: [],\n recommendedAction: reviewed.status === \"allowed\"\n ? \"Render the exact reviewed content.\"\n : \"Follow the signed runtime review decision.\",\n };\n return finalizeDecision(content, fingerprint, result, \"reviewed_memory\", strict);\n}\n\nfunction finalizeDecision(\n content: HalalRuntimeContent,\n fingerprint: string,\n result: HalalCheckResult,\n source: HalalRuntimeDecision[\"source\"],\n strict: boolean,\n): HalalRuntimeDecision {\n return {\n ...result,\n contentKind: content.kind,\n fingerprint,\n source,\n allowed: result.status === \"allowed\" || (result.status === \"warning\" && !strict),\n };\n}\n\nfunction mergeResults(left: HalalCheckResult, right: HalalCheckResult): HalalCheckResult {\n const leftRank = STATUS_RANK[left.status];\n const rightRank = STATUS_RANK[right.status];\n const dominant = rightRank > leftRank ? right : left;\n const riskLevel = RISK_RANK[right.riskLevel] > RISK_RANK[left.riskLevel]\n ? right.riskLevel\n : left.riskLevel;\n const confidence = leftRank === rightRank\n ? Math.max(left.confidence, right.confidence)\n : dominant.confidence;\n\n return {\n status: dominant.status,\n riskLevel,\n categories: uniqueStrings([...left.categories, ...right.categories]),\n confidence,\n reasons: uniqueStrings([...left.reasons, ...right.reasons]),\n matchedFiles: uniqueStrings([...left.matchedFiles, ...right.matchedFiles]),\n matchedSnippets: uniqueStrings([...left.matchedSnippets, ...right.matchedSnippets]),\n recommendedAction: dominant.recommendedAction,\n };\n}\n\nfunction uniqueStrings(values: string[]): string[] {\n return [...new Set(values.filter(Boolean))];\n}\n"],"mappings":";;;;;;AAkBA,MAAM,cAAgD;CACpD,SAAS;CACT,SAAS;CACT,iBAAiB;CACjB,SAAS;AACX;AAEA,MAAM,YAA2D;CAC/D,KAAK;CACL,QAAQ;CACR,MAAM;CACN,UAAU;AACZ;AAEA,IAAa,2BAAb,cAA8C,MAAM;CAClD;CAEA,YAAY,UAAgC;EAC1C,MAAM,SAAS,QAAQ,MAAM,kDAAkD;EAC/E,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;AAEA,SAAgB,wBAAwB,UAAoC,CAAC,GAAG;CAC9E,OAAO;EACL,MAAM,SAA6D;GACjE,OAAO,4BAA4B,SAAS,OAAO;EACrD;EAEA,iBAAiB,SAA2E;GAC1F,OAAO,4BAA4B;IAAE,GAAG;IAAS,MAAM;GAAe,GAAG,OAAO;EAClF;EAEA,QAAQ,SAA2E;GACjF,OAAO,4BAA4B;IAAE,GAAG;IAAS,MAAM;GAAgB,GAAG,OAAO;EACnF;EAEA,MAAM,cAAc,SAA6D;GAC/E,MAAM,WAAW,MAAM,4BAA4B,SAAS,OAAO;GACnE,IAAI,CAAC,SAAS,SACZ,MAAM,IAAI,yBAAyB,QAAQ;GAE7C,OAAO;EACT;EAEA,MAAM,UAAuD,KAAmB;GAC9E,MAAM,UAAU,MA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GAAG,KAAK,iBAAiB,GAAG,MAAM,eAAe,CAAC;EAClF,mBAAmB,SAAS;CAC9B;AACF;AAEA,SAAS,cAAc,QAA4B;CACjD,OAAO,CAAC,GAAG,IAAI,IAAI,OAAO,OAAO,OAAO,CAAC,CAAC;AAC5C"}
|
|
1
|
+
{"version":3,"file":"guard.js","names":[],"sources":["../../../src/halal-core/runtime/guard.ts"],"sourcesContent":["import { classifyRuntimeContentWithAi } from \"../ai/classifyRuntimeContent.js\";\nimport { evaluateRules } from \"../rules/defaultBlockedRules.js\";\nimport { scanDomains } from \"../scanner/scanDomains.js\";\nimport type { HalalCheckResult, HalalGuardStatus } from \"../status.js\";\nimport {\n createRuntimeContentFingerprint,\n findReviewedRuntimeDecision,\n} from \"./reviewedMemory.js\";\nimport {\n prepareRuntimeContent,\n type RuntimeContentInspectionIssue,\n} from \"./serializeRuntimeContent.js\";\nimport type {\n HalalRuntimeContent,\n HalalRuntimeDecision,\n HalalRuntimeGuardOptions,\n} from \"./types.js\";\n\nconst STATUS_RANK: Record<HalalGuardStatus, number> = {\n allowed: 0,\n warning: 1,\n review_required: 2,\n blocked: 3,\n};\n\nconst RISK_RANK: Record<HalalCheckResult[\"riskLevel\"], number> = {\n low: 0,\n medium: 1,\n high: 2,\n critical: 3,\n};\n\nexport class HalalRuntimeBlockedError extends Error {\n readonly decision: HalalRuntimeDecision;\n\n constructor(decision: HalalRuntimeDecision) {\n super(decision.reasons[0] || \"Runtime content was rejected by the halal guard.\");\n this.name = \"HalalRuntimeBlockedError\";\n this.decision = decision;\n }\n}\n\nexport function createHalalRuntimeGuard(options: HalalRuntimeGuardOptions = {}) {\n return {\n check(content: HalalRuntimeContent): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent(content, options);\n },\n\n checkDynamicPage(content: Omit<HalalRuntimeContent, \"kind\">): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent({ ...content, kind: \"dynamic_page\" }, options);\n },\n\n checkAd(content: Omit<HalalRuntimeContent, \"kind\">): Promise<HalalRuntimeDecision> {\n return evaluateHalalRuntimeContent({ ...content, kind: \"advertisement\" }, options);\n },\n\n async assertAllowed(content: HalalRuntimeContent): Promise<HalalRuntimeDecision> {\n const decision = await evaluateHalalRuntimeContent(content, options);\n if (!decision.allowed) {\n throw new HalalRuntimeBlockedError(decision);\n }\n return decision;\n },\n\n async filterAds<T extends Omit<HalalRuntimeContent, \"kind\">>(ads: readonly T[]) {\n const checked = await Promise.all(ads.map(async (ad) => ({\n ad,\n decision: await evaluateHalalRuntimeContent({ ...ad, kind: \"advertisement\" }, options),\n })));\n return {\n allowed: checked.filter((entry) => entry.decision.allowed).map((entry) => entry.ad),\n rejected: checked.filter((entry) => !entry.decision.allowed),\n };\n },\n };\n}\n\nexport async function evaluateHalalRuntimeContent(\n content: HalalRuntimeContent,\n options: HalalRuntimeGuardOptions = {},\n): Promise<HalalRuntimeDecision> {\n const serialized = prepareRuntimeContent(content, options.maxContentCharacters);\n const fingerprint = createRuntimeContentFingerprint(content);\n const file = `runtime:${content.kind}:${content.id || content.route || \"anonymous\"}`;\n const scannedResult = evaluateRules({\n routes: content.route ? [content.route] : [],\n pages: content.kind === \"dynamic_page\" && content.route ? [content.route] : [],\n components: [],\n metadata: {\n title: content.title,\n description: content.advertiser\n ? `Advertiser: ${content.advertiser}`\n : `${content.kind} runtime content`,\n },\n envNames: [],\n dependencies: {},\n i18nWords: [],\n contentTexts: [{ file, text: serialized.localText }],\n endpoints: scanDomains([{ file, text: serialized.localText }]),\n }, options.policy ?? {});\n\n let localResult = scannedResult;\n if (serialized.truncated) {\n localResult = mergeResults(\n localResult,\n truncatedContentResult(file, serialized.maxCharacters),\n );\n }\n if (serialized.inspectionIssues.length > 0) {\n localResult = mergeResults(\n localResult,\n uninspectableContentResult(file, serialized.inspectionIssues),\n );\n }\n\n const reviewed = findReviewedRuntimeDecision(\n content,\n options.reviewedDecisions,\n options.reviewSecret,\n );\n if (reviewed) {\n const reviewedResult = decisionFromReviewedMemory(content, fingerprint, reviewed, options.strict === true);\n if (STATUS_RANK[reviewedResult.status] >= STATUS_RANK[localResult.status]\n || STATUS_RANK[localResult.status] <= STATUS_RANK.warning) {\n return reviewedResult;\n }\n }\n\n if (localResult.status === \"blocked\") {\n return finalizeDecision(content, fingerprint, localResult, \"local_rules\", options.strict === true);\n }\n\n const aiResult = await classifyRuntimeContentWithAi(\n content,\n serialized.aiText,\n localResult,\n options.ai,\n );\n const requiresAi = content.kind === \"advertisement\"\n ? options.ai?.requireForAds !== false\n : options.ai?.requireForDynamicContent === true;\n\n if (!aiResult && requiresAi) {\n const unverified = mergeResults(localResult, {\n status: \"review_required\",\n riskLevel: \"medium\",\n categories: [content.kind === \"advertisement\" ? \"unverified_ad\" : \"unverified_dynamic_content\"],\n confidence: 0,\n reasons: [\"Required runtime AI verification is not configured or unavailable.\"],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Do not render this content until AI verification or signed human review is available.\",\n });\n return finalizeDecision(content, fingerprint, unverified, \"local_rules\", options.strict === true);\n }\n\n const result = aiResult ? mergeResults(localResult, aiResult) : localResult;\n return finalizeDecision(\n content,\n fingerprint,\n result,\n aiResult ? \"local_and_ai\" : \"local_rules\",\n options.strict === true,\n );\n}\n\nfunction truncatedContentResult(file: string, maxCharacters: number): HalalCheckResult {\n return {\n status: \"review_required\",\n riskLevel: \"medium\",\n categories: [\"runtime_content_truncated\"],\n confidence: 1,\n reasons: [\n `Runtime content exceeded the ${maxCharacters}-character scan limit and was not fully inspected.`,\n ],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Increase maxContentCharacters or complete a manual review before rendering.\",\n };\n}\n\nfunction uninspectableContentResult(\n file: string,\n issues: readonly RuntimeContentInspectionIssue[],\n): HalalCheckResult {\n const issueDescriptions = issues.map((issue) => {\n if (issue === \"max_depth\") return \"maximum serialization depth was reached\";\n if (issue === \"unreadable_property\") return \"one or more properties could not be read\";\n return \"one or more objects could not be inspected\";\n });\n\n return {\n status: \"review_required\",\n riskLevel: \"high\",\n categories: [\"runtime_content_uninspectable\"],\n confidence: 1,\n reasons: [\n `Runtime content could not be fully inspected: ${uniqueStrings(issueDescriptions).join(\"; \")}.`,\n ],\n matchedFiles: [file],\n matchedSnippets: [],\n recommendedAction: \"Normalize runtime content to plain inspectable data or complete a manual review before rendering.\",\n };\n}\n\nfunction decisionFromReviewedMemory(\n content: HalalRuntimeContent,\n fingerprint: string,\n reviewed: NonNullable<HalalRuntimeGuardOptions[\"reviewedDecisions\"]>[number],\n strict: boolean,\n): HalalRuntimeDecision {\n const result: HalalCheckResult = {\n status: reviewed.status,\n riskLevel: reviewed.status === \"blocked\"\n ? \"high\"\n : reviewed.status === \"review_required\"\n ? \"medium\"\n : reviewed.status === \"warning\"\n ? \"medium\"\n : \"low\",\n categories: reviewed.categories,\n confidence: 1,\n reasons: [`Signed review by ${reviewed.reviewerId}: ${reviewed.reason}`],\n matchedFiles: [],\n matchedSnippets: [],\n recommendedAction: reviewed.status === \"allowed\"\n ? \"Render the exact reviewed content.\"\n : \"Follow the signed runtime review decision.\",\n };\n return finalizeDecision(content, fingerprint, result, \"reviewed_memory\", strict);\n}\n\nfunction finalizeDecision(\n content: HalalRuntimeContent,\n fingerprint: string,\n result: HalalCheckResult,\n source: HalalRuntimeDecision[\"source\"],\n strict: boolean,\n): HalalRuntimeDecision {\n return {\n ...result,\n contentKind: content.kind,\n fingerprint,\n source,\n allowed: result.status === \"allowed\" || (result.status === \"warning\" && !strict),\n };\n}\n\nfunction mergeResults(left: HalalCheckResult, right: HalalCheckResult): HalalCheckResult {\n const leftRank = STATUS_RANK[left.status];\n const rightRank = STATUS_RANK[right.status];\n const dominant = rightRank > leftRank ? right : left;\n const riskLevel = RISK_RANK[right.riskLevel] > RISK_RANK[left.riskLevel]\n ? right.riskLevel\n : left.riskLevel;\n const confidence = leftRank === rightRank\n ? Math.max(left.confidence, right.confidence)\n : dominant.confidence;\n\n return {\n status: dominant.status,\n riskLevel,\n categories: uniqueStrings([...left.categories, ...right.categories]),\n confidence,\n reasons: uniqueStrings([...left.reasons, ...right.reasons]),\n matchedFiles: uniqueStrings([...left.matchedFiles, ...right.matchedFiles]),\n matchedSnippets: uniqueStrings([...left.matchedSnippets, ...right.matchedSnippets]),\n recommendedAction: dominant.recommendedAction,\n };\n}\n\nfunction uniqueStrings(values: string[]): string[] {\n return [...new Set(values.filter(Boolean))];\n}\n"],"mappings":";;;;;;AAkBA,MAAM,cAAgD;CACpD,SAAS;CACT,SAAS;CACT,iBAAiB;CACjB,SAAS;AACX;AAEA,MAAM,YAA2D;CAC/D,KAAK;CACL,QAAQ;CACR,MAAM;CACN,UAAU;AACZ;AAEA,IAAa,2BAAb,cAA8C,MAAM;CACzC;CAET,YAAY,UAAgC;EAC1C,MAAM,SAAS,QAAQ,MAAM,kDAAkD;EAC/E,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;AAEA,SAAgB,wBAAwB,UAAoC,CAAC,GAAG;CAC9E,OAAO;EACL,MAAM,SAA6D;GACjE,OAAO,4BAA4B,SAAS,OAAO;EACrD;EAEA,iBAAiB,SAA2E;GAC1F,OAAO,4BAA4B;IAAE,GAAG;IAAS,MAAM;GAAe,GAAG,OAAO;EAClF;EAEA,QAAQ,SAA2E;GACjF,OAAO,4BAA4B;IAAE,GAAG;IAAS,MAAM;GAAgB,GAAG,OAAO;EACnF;EAEA,MAAM,cAAc,SAA6D;GAC/E,MAAM,WAAW,MAAM,4BAA4B,SAAS,OAAO;GACnE,IAAI,CAAC,SAAS,SACZ,MAAM,IAAI,yBAAyB,QAAQ;GAE7C,OAAO;EACT;EAEA,MAAM,UAAuD,KAAmB;GAC9E,MAAM,UAAU,MAAM,QAAQ,IAAI,IAAI,IAAI,OAAO,QAAQ;IACvD;IACA,UAAU,MAAM,4BAA4B;KAAE,GAAG;KAAI,MAAM;IAAgB,GAAG,OAAO;GACvF,EAAE,CAAC;GACH,OAAO;IACL,SAAS,QAAQ,QAAQ,UAAU,MAA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|
@@ -2,5 +2,4 @@ import { HalalRuntimeContent, HalalRuntimeReviewInput, SignedHalalRuntimeDecisio
|
|
|
2
2
|
export declare function createRuntimeContentFingerprint(content: HalalRuntimeContent, _maxContentCharacters?: number): string;
|
|
3
3
|
export declare function createSignedHalalRuntimeDecision(content: HalalRuntimeContent, review: HalalRuntimeReviewInput, secret?: string): SignedHalalRuntimeDecision;
|
|
4
4
|
export declare function verifySignedHalalRuntimeDecision(decision: unknown, secret?: string): decision is SignedHalalRuntimeDecision;
|
|
5
|
-
export declare function findReviewedRuntimeDecision(content: HalalRuntimeContent, decisions: readonly SignedHalalRuntimeDecision[] | undefined, secret?: string, _maxContentCharacters?: number): SignedHalalRuntimeDecision | undefined;
|
|
6
|
-
//# sourceMappingURL=reviewedMemory.d.ts.map
|
|
5
|
+
export declare function findReviewedRuntimeDecision(content: HalalRuntimeContent, decisions: readonly SignedHalalRuntimeDecision[] | undefined, secret?: string, _maxContentCharacters?: number): SignedHalalRuntimeDecision | undefined;
|
|
@@ -10,5 +10,4 @@ export interface PreparedRuntimeContent {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function serializeRuntimeContent(content: HalalRuntimeContent, maxCharacters?: number): string;
|
|
12
12
|
export declare function prepareRuntimeContent(content: HalalRuntimeContent, maxCharacters?: number): PreparedRuntimeContent;
|
|
13
|
-
export declare function serializeRuntimeContentCanonical(content: HalalRuntimeContent): string;
|
|
14
|
-
//# sourceMappingURL=serializeRuntimeContent.d.ts.map
|
|
13
|
+
export declare function serializeRuntimeContentCanonical(content: HalalRuntimeContent): string;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanApiRoutes(appRoot: string): string[];
|
|
2
|
-
//# sourceMappingURL=scanApiRoutes.d.ts.map
|
|
1
|
+
export declare function scanApiRoutes(appRoot: string): string[];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanComponents(appRoot: string): string[];
|
|
2
|
-
//# sourceMappingURL=scanComponents.d.ts.map
|
|
1
|
+
export declare function scanComponents(appRoot: string): string[];
|
|
@@ -2,5 +2,4 @@ export interface ScanResult {
|
|
|
2
2
|
file: string;
|
|
3
3
|
text: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function scanContentFiles(dir: string, appRoot: string, ignoredPaths?: Set<string>): ScanResult[];
|
|
6
|
-
//# sourceMappingURL=scanContent.d.ts.map
|
|
5
|
+
export declare function scanContentFiles(dir: string, appRoot: string, ignoredPaths?: Set<string>): ScanResult[];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanDependencies(appRoot: string): Record<string, string>;
|
|
2
|
-
//# sourceMappingURL=scanDependencies.d.ts.map
|
|
1
|
+
export declare function scanDependencies(appRoot: string): Record<string, string>;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanEnvNames(appRoot: string): string[];
|
|
2
|
-
//# sourceMappingURL=scanEnvNames.d.ts.map
|
|
1
|
+
export declare function scanEnvNames(appRoot: string): string[];
|
|
@@ -3,5 +3,4 @@ export interface ScanMetadataResult {
|
|
|
3
3
|
description?: string;
|
|
4
4
|
meta?: Record<string, string>;
|
|
5
5
|
}
|
|
6
|
-
export declare function scanMetadata(appRoot: string): ScanMetadataResult;
|
|
7
|
-
//# sourceMappingURL=scanMetadata.d.ts.map
|
|
6
|
+
export declare function scanMetadata(appRoot: string): ScanMetadataResult;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanPages(appRoot: string): string[];
|
|
2
|
-
//# sourceMappingURL=scanPages.d.ts.map
|
|
1
|
+
export declare function scanPages(appRoot: string): string[];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanRoutes(appRoot: string): string[];
|
|
2
|
-
//# sourceMappingURL=scanRoutes.d.ts.map
|
|
1
|
+
export declare function scanRoutes(appRoot: string): string[];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function scanTranslations(appRoot: string): string[];
|
|
2
|
-
//# sourceMappingURL=scanTranslations.d.ts.map
|
|
1
|
+
export declare function scanTranslations(appRoot: string): string[];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function verifyCoreIntegrity(appRoot: string): boolean;
|
|
2
|
-
//# sourceMappingURL=verifyCoreIntegrity.d.ts.map
|
|
1
|
+
export declare function verifyCoreIntegrity(appRoot: string): boolean;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function verifyLifecycleHooksRegistered(hooks: any): boolean;
|
|
2
|
-
//# sourceMappingURL=verifyLifecycleHooks.d.ts.map
|
|
1
|
+
export declare function verifyLifecycleHooksRegistered(hooks: any): boolean;
|
|
@@ -2,5 +2,4 @@ import { ReportVerificationOptions } from "../report/verifyReport.js";
|
|
|
2
2
|
export declare function checkOnDiskReportSignature(outDir: string, options?: ReportVerificationOptions): {
|
|
3
3
|
valid: boolean;
|
|
4
4
|
reason?: string;
|
|
5
|
-
};
|
|
6
|
-
//# sourceMappingURL=verifyReportSignature.d.ts.map
|
|
5
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for working with Resux head entries and Content
|
|
3
|
+
* Security Policy strings. Used by the runtime head renderer, the
|
|
4
|
+
* module container, and the compiler.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Deduplicate head script entries by their stable identity
|
|
8
|
+
* (key, then id, then src), keeping the latest occurrence in place.
|
|
9
|
+
*/
|
|
10
|
+
export declare function dedupeHeadScripts(scripts: unknown[]): Array<Record<string, unknown>>;
|
|
11
|
+
/**
|
|
12
|
+
* Read the source list of the first matching CSP directive.
|
|
13
|
+
* Returns null when no matching directive is present.
|
|
14
|
+
*/
|
|
15
|
+
export declare function cspDirectiveSources(csp: string, names: string[]): string[] | null;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/head/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shared helpers for working with Resux head entries and Content
|
|
4
|
+
* Security Policy strings. Used by the runtime head renderer, the
|
|
5
|
+
* module container, and the compiler.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Deduplicate head script entries by their stable identity
|
|
9
|
+
* (key, then id, then src), keeping the latest occurrence in place.
|
|
10
|
+
*/
|
|
11
|
+
function dedupeHeadScripts(scripts) {
|
|
12
|
+
const map = /* @__PURE__ */ new Map();
|
|
13
|
+
const result = [];
|
|
14
|
+
for (const item of scripts) {
|
|
15
|
+
if (!item || typeof item !== "object") continue;
|
|
16
|
+
const script = item;
|
|
17
|
+
const dedupeKey = script.key ?? script.id ?? script.src;
|
|
18
|
+
if (dedupeKey) {
|
|
19
|
+
if (map.has(dedupeKey)) {
|
|
20
|
+
const existing = map.get(dedupeKey);
|
|
21
|
+
const idx = result.indexOf(existing);
|
|
22
|
+
if (idx !== -1) result[idx] = script;
|
|
23
|
+
map.set(dedupeKey, script);
|
|
24
|
+
} else {
|
|
25
|
+
map.set(dedupeKey, script);
|
|
26
|
+
result.push(script);
|
|
27
|
+
}
|
|
28
|
+
} else result.push(script);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Read the source list of the first matching CSP directive.
|
|
34
|
+
* Returns null when no matching directive is present.
|
|
35
|
+
*/
|
|
36
|
+
function cspDirectiveSources(csp, names) {
|
|
37
|
+
if (!csp.trim()) return null;
|
|
38
|
+
const directives = /* @__PURE__ */ new Map();
|
|
39
|
+
for (const rawDirective of csp.split(";")) {
|
|
40
|
+
const tokens = rawDirective.trim().split(/\s+/).filter(Boolean);
|
|
41
|
+
if (!tokens.length) continue;
|
|
42
|
+
directives.set(tokens[0].toLowerCase(), tokens.slice(1));
|
|
43
|
+
}
|
|
44
|
+
for (const name of names) {
|
|
45
|
+
const sources = directives.get(name);
|
|
46
|
+
if (sources) return sources;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
export { cspDirectiveSources, dedupeHeadScripts };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/head/utils.ts"],"sourcesContent":["/**\n * Shared helpers for working with Resux head entries and Content\n * Security Policy strings. Used by the runtime head renderer, the\n * module container, and the compiler.\n */\n\n/**\n * Deduplicate head script entries by their stable identity\n * (key, then id, then src), keeping the latest occurrence in place.\n */\nexport function dedupeHeadScripts(scripts: unknown[]): Array<Record<string, unknown>> {\n const map = new Map<string, Record<string, unknown>>();\n const result: Array<Record<string, unknown>> = [];\n for (const item of scripts) {\n if (!item || typeof item !== \"object\") continue;\n const script = item as Record<string, unknown>;\n const dedupeKey = (script.key as string) ?? (script.id as string) ?? (script.src as string);\n if (dedupeKey) {\n if (map.has(dedupeKey)) {\n const existing = map.get(dedupeKey)!;\n const idx = result.indexOf(existing);\n if (idx !== -1) {\n result[idx] = script;\n }\n map.set(dedupeKey, script);\n } else {\n map.set(dedupeKey, script);\n result.push(script);\n }\n } else {\n result.push(script);\n }\n }\n return result;\n}\n\n/**\n * Read the source list of the first matching CSP directive.\n * Returns null when no matching directive is present.\n */\nexport function cspDirectiveSources(csp: string, names: string[]): string[] | null {\n if (!csp.trim()) {\n return null;\n }\n const directives = new Map<string, string[]>();\n for (const rawDirective of csp.split(\";\")) {\n const tokens = rawDirective.trim().split(/\\s+/).filter(Boolean);\n if (!tokens.length) continue;\n directives.set(tokens[0].toLowerCase(), tokens.slice(1));\n }\n for (const name of names) {\n const sources = directives.get(name);\n if (sources) return sources;\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,kBAAkB,SAAoD;CACpF,MAAM,sBAAM,IAAI,IAAqC;CACrD,MAAM,SAAyC,CAAC;CAChD,KAAK,MAAM,QAAQ,SAAS;EAC1B,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU;EACvC,MAAM,SAAS;EACf,MAAM,YAAa,OAAO,OAAmB,OAAO,MAAkB,OAAO;EAC7E,IAAI,WAAW;GACb,IAAI,IAAI,IAAI,SAAS,GAAG;IACtB,MAAM,WAAW,IAAI,IAAI,SAAS;IAClC,MAAM,MAAM,OAAO,QAAQ,QAAQ;IACnC,IAAI,QAAQ,IACV,OAAO,OAAO;IAEhB,IAAI,IAAI,WAAW,MAAM;GAC3B,OAAO;IACL,IAAI,IAAI,WAAW,MAAM;IACzB,OAAO,KAAK,MAAM;GACpB;EACF,OACE,OAAO,KAAK,MAAM;CAEtB;CACA,OAAO;AACT;;;;;AAMA,SAAgB,oBAAoB,KAAa,OAAkC;CACjF,IAAI,CAAC,IAAI,KAAK,GACZ,OAAO;CAET,MAAM,6BAAa,IAAI,IAAsB;CAC7C,KAAK,MAAM,gBAAgB,IAAI,MAAM,GAAG,GAAG;EACzC,MAAM,SAAS,aAAa,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;EAC9D,IAAI,CAAC,OAAO,QAAQ;EACpB,WAAW,IAAI,OAAO,EAAE,CAAC,YAAY,GAAG,OAAO,MAAM,CAAC,CAAC;CACzD;CACA,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,UAAU,WAAW,IAAI,IAAI;EACnC,IAAI,SAAS,OAAO;CACtB;CACA,OAAO;AACT"}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -42,5 +42,4 @@ export declare function createI18nHeadEntry(routePath: string, routeOrigin?: str
|
|
|
42
42
|
link: Array<Record<string, string>>;
|
|
43
43
|
};
|
|
44
44
|
declare const _default: ResuxModule<ResuxI18nModuleOptions>;
|
|
45
|
-
export { _default as default };
|
|
46
|
-
//# sourceMappingURL=index.d.ts.map
|
|
45
|
+
export { _default as default };
|