Skip to content

Commit 154c5f5

Browse files
waleedlatif1claude
andcommitted
refactor(csp): extract shared getEmbedCSPPolicy helper
Deduplicate getChatEmbedCSPPolicy and getFormEmbedCSPPolicy into a shared private helper to prevent future divergence. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9f5141e commit 154c5f5

File tree

1 file changed

+11
-10
lines changed
  • apps/sim/lib/core/security

1 file changed

+11
-10
lines changed

apps/sim/lib/core/security/csp.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,27 +202,28 @@ export function getWorkflowExecutionCSPPolicy(): string {
202202
}
203203

204204
/**
205-
* CSP for embeddable chat pages
205+
* Shared CSP for embeddable pages (chat, forms)
206206
* Allows embedding in iframes from any origin while maintaining other security policies
207207
*/
208-
export function getChatEmbedCSPPolicy(): string {
209-
const basePolicy = buildCSPString({
208+
function getEmbedCSPPolicy(): string {
209+
return buildCSPString({
210210
...buildTimeCSPDirectives,
211211
'frame-ancestors': ['*'],
212212
})
213-
return basePolicy
213+
}
214+
215+
/**
216+
* CSP for embeddable chat pages
217+
*/
218+
export function getChatEmbedCSPPolicy(): string {
219+
return getEmbedCSPPolicy()
214220
}
215221

216222
/**
217223
* CSP for embeddable form pages
218-
* Allows embedding in iframes from any origin while maintaining other security policies
219224
*/
220225
export function getFormEmbedCSPPolicy(): string {
221-
const basePolicy = buildCSPString({
222-
...buildTimeCSPDirectives,
223-
'frame-ancestors': ['*'],
224-
})
225-
return basePolicy
226+
return getEmbedCSPPolicy()
226227
}
227228

228229
/**

0 commit comments

Comments
 (0)