Skip to content

Commit d6a7df6

Browse files
committed
fix: iframe timeout is not applied to load timer
1 parent 359d92f commit d6a7df6

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/utils/iframe.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ export function createHiddenFrame() {
1818
export function runIframe(url: string, options: IFrameOptions) {
1919
return new Promise<any>((resolve, reject) => {
2020
let onLoadTimeoutId: any = null
21+
const timeoutMs = (options.timeout || 10) * 1000
2122
const iframe = createHiddenFrame()
2223

23-
const timeoutSetTimeoutId = setTimeout(
24-
() => {
25-
reject(new OIDCClientError("Timed out"))
26-
removeIframe()
27-
},
28-
(options.timeout || 10) * 1000,
29-
)
24+
const timeoutSetTimeoutId = setTimeout(() => {
25+
reject(new OIDCClientError("Timed out"))
26+
removeIframe()
27+
}, timeoutMs)
3028

3129
const iframeEventHandler = (e: MessageEvent) => {
3230
if (e.origin !== options.eventOrigin) return
@@ -60,7 +58,7 @@ export function runIframe(url: string, options: IFrameOptions) {
6058
setTimeout(() => {
6159
reject(new OIDCClientError("Could not complete silent authentication", url))
6260
removeIframe()
63-
}, 300)
61+
}, timeoutMs)
6462

6563
window.addEventListener("message", iframeEventHandler, false)
6664
window.document.body.appendChild(iframe)

src/utils/popup.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,18 @@ export function runPopup(url: string, options: PopupOptions) {
3636
window.removeEventListener("message", messageListener)
3737
}
3838

39-
timeoutId = setTimeout(
40-
() => {
41-
clearHandlers()
42-
reject(new OIDCClientError("Timed out"))
43-
},
44-
options.timeout || 60 * 1000,
45-
)
39+
const timeoutMs = (options.timeout || 60) * 1000
40+
timeoutId = setTimeout(() => {
41+
clearHandlers()
42+
reject(new OIDCClientError("Timed out"))
43+
}, timeoutMs)
4644

4745
closeId = setInterval(() => {
4846
if (popup!.closed) {
4947
clearHandlers()
5048
reject(new InteractionCancelled("user closed popup"))
5149
}
52-
}, 300)
50+
}, timeoutMs)
5351

5452
window.addEventListener("message", messageListener)
5553

0 commit comments

Comments
 (0)