(url: string)
| 1206 | * @returns true if the URL is safe to redirect to |
| 1207 | */ |
| 1208 | export function validateCallbackUrl(url: string): boolean { |
| 1209 | try { |
| 1210 | if (typeof url !== 'string' || url.length === 0) return false |
| 1211 | |
| 1212 | const base = typeof window === 'undefined' ? CALLBACK_URL_SERVER_BASE : window.location.origin |
| 1213 | const parsed = new URL(url, base) |
| 1214 | return parsed.origin === base |
| 1215 | } catch (error) { |
| 1216 | logger.error('Error validating callback URL:', { error, url }) |
| 1217 | return false |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | const OKTA_DOMAIN_PATTERN = |
| 1222 | /^[a-zA-Z0-9][a-zA-Z0-9-]*\.(okta|okta-gov|okta-emea|oktapreview|trexcloud)\.com$/ |
no test coverage detected