Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove iframe-resizer package #34

Merged
merged 3 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@authsignal/browser",
"version": "0.1.3",
"version": "0.1.4",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand All @@ -24,7 +24,6 @@
"@fingerprintjs/fingerprintjs": "^3.3.6",
"@simplewebauthn/browser": "^7.2.0",
"a11y-dialog": "^7.5.2",
"iframe-resizer": "^4.3.6",
"ky": "^0.33.3",
"uuid": "^9.0.0"
},
Expand Down
27 changes: 13 additions & 14 deletions src/popup-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import A11yDialog from "a11y-dialog";
import "iframe-resizer/js/iframeResizer";
import "iframe-resizer/js/iframeResizer.contentWindow";

const CONTAINER_ID = "__authsignal-popup-container";
const CONTENT_ID = "__authsignal-popup-content";
Expand All @@ -24,7 +22,6 @@ type PopupHandlerOptions = {

class PopupHandler {
private popup: A11yDialog | null = null;
private isHeightAutoResized = true;

constructor({width}: PopupHandlerOptions) {
if (document.querySelector(`#${CONTAINER_ID}`)) {
Expand Down Expand Up @@ -124,6 +121,8 @@ class PopupHandler {
document.body.removeChild(dialogEl);
document.head.removeChild(styleEl);
}

window.removeEventListener("message", resizeIframe);
}

show({url}: PopupShowInput) {
Expand All @@ -146,17 +145,9 @@ class PopupHandler {
dialogContent.appendChild(iframe);
}

// @ts-expect-error can't get typescript import to behave nicely, this works though
iFrameResize(
{
checkOrigin: false,
scrolling: true,
onInit: () => {
this.popup?.show();
},
},
iframe
);
window.addEventListener("message", resizeIframe);

this.popup?.show();
}

close() {
Expand All @@ -176,4 +167,12 @@ class PopupHandler {
}
}

function resizeIframe(event: MessageEvent) {
const iframeEl = document.querySelector<HTMLIFrameElement>(`#${IFRAME_ID}`);

if (iframeEl && event.data.height) {
iframeEl.style.height = event.data.height + "px";
}
}

export {PopupHandler};