File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
packages/clerk-js/src/utils Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/clerk-js ' : patch
3+ ---
4+
5+ fix(clerk-js): update inCrossOriginIframe to handle nested cross origin iframes
Original file line number Diff line number Diff line change @@ -21,7 +21,19 @@ export function inIframe() {
2121}
2222
2323export function inCrossOriginIframe ( ) {
24- // https://developer.mozilla.org/en-US/docs/Web/API/Window/frameElement
25- // frameElement: if the document into which it's embedded has a different origin, the value is null instead.
26- return inIframe ( ) && ! window . frameElement ;
24+ if ( ! inIframe ( ) ) {
25+ return false ;
26+ }
27+
28+ try {
29+ // Try to access top window's location to check if any ancestor is cross-origin
30+ // This will throw a SecurityError if any iframe in the chain is cross-origin
31+ // Handles nested iframes where immediate parent might be same-origin
32+ // but a higher-level ancestor is cross-origin
33+ void window . top ?. location . href ;
34+ return false ;
35+ } catch {
36+ // SecurityError thrown - we're in a cross-origin iframe (at any level)
37+ return true ;
38+ }
2739}
You can’t perform that action at this time.
0 commit comments