mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 03:03:43 +00:00
* add csp and only pass hostname to duo init * expand style-src * Update apps/web/src/connectors/duo.html Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com> Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import * as DuoWebSDK from "duo_web_sdk";
|
|
|
|
import { getQsParam } from "./common";
|
|
|
|
require("./duo.scss");
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
const frameElement = document.createElement("iframe");
|
|
frameElement.setAttribute("id", "duo_iframe");
|
|
setFrameHeight();
|
|
document.body.appendChild(frameElement);
|
|
|
|
const hostParam = getQsParam("host");
|
|
const requestParam = getQsParam("request");
|
|
|
|
const hostUrl = new URL("https://" + hostParam);
|
|
if (
|
|
!hostUrl.hostname.endsWith(".duosecurity.com") &&
|
|
!hostUrl.hostname.endsWith(".duofederal.com")
|
|
) {
|
|
return;
|
|
}
|
|
|
|
DuoWebSDK.init({
|
|
iframe: "duo_iframe",
|
|
host: hostUrl.hostname,
|
|
sig_request: requestParam,
|
|
submit_callback: (form: any) => {
|
|
invokeCSCode(form.elements.sig_response.value);
|
|
},
|
|
});
|
|
|
|
window.onresize = setFrameHeight;
|
|
|
|
function setFrameHeight() {
|
|
frameElement.style.height = window.innerHeight + "px";
|
|
}
|
|
});
|
|
|
|
function invokeCSCode(data: string) {
|
|
try {
|
|
(window as any).invokeCSharpAction(data);
|
|
} catch (err) {
|
|
// eslint-disable-next-line
|
|
console.log(err);
|
|
}
|
|
}
|