Skip to content

Commit

Permalink
fix: block non https urls (#295)
Browse files Browse the repository at this point in the history
Co-authored-by: Praful Koppalkar <[email protected]>
Co-authored-by: Arush <[email protected]>
  • Loading branch information
3 people authored Apr 18, 2024
1 parent e4d2243 commit 2c745eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Window.res
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ external hostname: string = "hostname"
@val @scope(("window", "location"))
external href: string = "href"

@val @scope(("window", "location"))
external protocol: string = "protocol"

let isSandbox = hostname === "beta.hyperswitch.io"

let isInteg = hostname === "dev.hyperswitch.io"
Expand Down
6 changes: 6 additions & 0 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
logger.setLogInfo(~value=Window.href, ~eventName=APP_INITIATED, ~timestamp=sdkTimestamp, ())
}
}->Sentry.sentryLogger
let isSecure = Window.protocol === "https:"
let isLocal = GlobalVars.sdkUrl->String.includes("localhost")
if !isSecure && !isLocal {
manageErrorWarning(HTTP_NOT_ALLOWED, ~dynamicStr=Window.href, ~logger, ())
Exn.raiseError("Insecure domain: " ++ Window.href)
}
switch Window.getHyper->Nullable.toOption {
| Some(hyperMethod) => {
logger.setLogInfo(
Expand Down

0 comments on commit 2c745eb

Please sign in to comment.