@rhinestone/1auth 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-Di8SBnPO.d.mts → client-CHCVV9H3.d.mts} +4 -1
- package/dist/{client-Di8SBnPO.d.ts → client-CHCVV9H3.d.ts} +4 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +64 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -93
- package/dist/index.mjs.map +1 -1
- package/dist/{provider-8anOtc87.d.mts → provider-B5pLvKo_.d.mts} +1 -1
- package/dist/{provider-CFnLQt5m.d.ts → provider-DzxXGyV8.d.ts} +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/wagmi.d.mts +2 -2
- package/dist/wagmi.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -26,7 +26,6 @@ var POPUP_WIDTH = 450;
|
|
|
26
26
|
var POPUP_HEIGHT = 600;
|
|
27
27
|
var DEFAULT_EMBED_WIDTH = "400px";
|
|
28
28
|
var DEFAULT_EMBED_HEIGHT = "500px";
|
|
29
|
-
var MODAL_WIDTH = 340;
|
|
30
29
|
var DEFAULT_PROVIDER_URL = "https://passkey.1auth.box";
|
|
31
30
|
var OneAuthClient = class {
|
|
32
31
|
constructor(config) {
|
|
@@ -555,7 +554,7 @@ var OneAuthClient = class {
|
|
|
555
554
|
if (event.origin !== dialogOrigin) return;
|
|
556
555
|
if (event.data?.type === "PASSKEY_READY") {
|
|
557
556
|
iframe.contentWindow?.postMessage(
|
|
558
|
-
{ type: "PASSKEY_INIT", ...initPayload },
|
|
557
|
+
{ type: "PASSKEY_INIT", ...initPayload, fullViewport: true },
|
|
559
558
|
dialogOrigin
|
|
560
559
|
);
|
|
561
560
|
}
|
|
@@ -894,7 +893,7 @@ var OneAuthClient = class {
|
|
|
894
893
|
if (event.origin !== dialogOrigin) return;
|
|
895
894
|
if (event.data?.type === "PASSKEY_READY") {
|
|
896
895
|
iframe.contentWindow?.postMessage(
|
|
897
|
-
{ type: "PASSKEY_INIT", ...batchInitPayload },
|
|
896
|
+
{ type: "PASSKEY_INIT", ...batchInitPayload, fullViewport: true },
|
|
898
897
|
dialogOrigin
|
|
899
898
|
);
|
|
900
899
|
}
|
|
@@ -1227,7 +1226,7 @@ var OneAuthClient = class {
|
|
|
1227
1226
|
ready: true,
|
|
1228
1227
|
sendInit: (initMessage) => {
|
|
1229
1228
|
iframe.contentWindow?.postMessage(
|
|
1230
|
-
{ type: "PASSKEY_INIT", ...initMessage },
|
|
1229
|
+
{ type: "PASSKEY_INIT", ...initMessage, fullViewport: true },
|
|
1231
1230
|
dialogOrigin
|
|
1232
1231
|
);
|
|
1233
1232
|
}
|
|
@@ -1961,7 +1960,8 @@ var OneAuthClient = class {
|
|
|
1961
1960
|
teardown();
|
|
1962
1961
|
iframe.contentWindow?.postMessage({
|
|
1963
1962
|
type: "PASSKEY_INIT",
|
|
1964
|
-
...initMessage
|
|
1963
|
+
...initMessage,
|
|
1964
|
+
fullViewport: true
|
|
1965
1965
|
}, dialogOrigin);
|
|
1966
1966
|
resolve(true);
|
|
1967
1967
|
} else if (event.data?.type === "PASSKEY_CLOSE") {
|
|
@@ -1984,121 +1984,88 @@ var OneAuthClient = class {
|
|
|
1984
1984
|
});
|
|
1985
1985
|
}
|
|
1986
1986
|
/**
|
|
1987
|
-
* Create a modal dialog with
|
|
1987
|
+
* Create a modal dialog with a full-viewport iframe inside.
|
|
1988
|
+
* All visual chrome (backdrop, positioning, animations) is rendered
|
|
1989
|
+
* by the passkey app inside the iframe — the SDK just provides
|
|
1990
|
+
* a transparent full-screen container.
|
|
1988
1991
|
*/
|
|
1989
1992
|
createModalDialog(url) {
|
|
1990
1993
|
const dialogUrl = this.getDialogUrl();
|
|
1991
1994
|
const hostUrl = new URL(dialogUrl);
|
|
1992
1995
|
const dialog = document.createElement("dialog");
|
|
1993
1996
|
dialog.dataset.passkey = "";
|
|
1997
|
+
dialog.style.opacity = "0";
|
|
1998
|
+
dialog.style.background = "transparent";
|
|
1994
1999
|
document.body.appendChild(dialog);
|
|
1995
2000
|
const style = document.createElement("style");
|
|
1996
2001
|
style.textContent = `
|
|
1997
2002
|
dialog[data-passkey] {
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2003
|
+
position: fixed;
|
|
2004
|
+
top: 0;
|
|
2005
|
+
left: 0;
|
|
2006
|
+
width: 100vw;
|
|
2007
|
+
height: 100vh;
|
|
2008
|
+
height: 100dvh;
|
|
2001
2009
|
max-width: none;
|
|
2002
2010
|
max-height: none;
|
|
2003
2011
|
margin: 0;
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
transform: translateX(-50%);
|
|
2012
|
+
padding: 0;
|
|
2013
|
+
border: none;
|
|
2014
|
+
background: transparent;
|
|
2008
2015
|
outline: none;
|
|
2016
|
+
overflow: hidden;
|
|
2017
|
+
pointer-events: auto;
|
|
2009
2018
|
}
|
|
2010
|
-
|
|
2011
2019
|
dialog[data-passkey]::backdrop {
|
|
2012
|
-
background
|
|
2013
|
-
backdrop-filter: blur(8px);
|
|
2014
|
-
-webkit-backdrop-filter: blur(8px);
|
|
2020
|
+
background: transparent !important;
|
|
2015
2021
|
}
|
|
2016
|
-
|
|
2017
2022
|
dialog[data-passkey] iframe {
|
|
2023
|
+
position: fixed;
|
|
2024
|
+
top: 0;
|
|
2025
|
+
left: 0;
|
|
2026
|
+
width: 100%;
|
|
2027
|
+
height: 100%;
|
|
2028
|
+
border: 0;
|
|
2018
2029
|
background-color: transparent;
|
|
2019
|
-
|
|
2020
|
-
border: none;
|
|
2021
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
2022
|
-
transition: height 0.15s ease-out;
|
|
2023
|
-
max-height: calc(100vh - 100px);
|
|
2024
|
-
max-height: calc(100dvh - 100px);
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
@media (min-width: 769px) {
|
|
2028
|
-
dialog[data-passkey] iframe {
|
|
2029
|
-
animation: passkey_zoomIn 0.2s cubic-bezier(0.32, 0.72, 0, 1);
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
@media (max-width: 768px) {
|
|
2034
|
-
dialog[data-passkey] {
|
|
2035
|
-
width: 100vw !important;
|
|
2036
|
-
height: auto !important;
|
|
2037
|
-
max-height: 90vh !important;
|
|
2038
|
-
max-height: 90dvh !important;
|
|
2039
|
-
top: auto !important;
|
|
2040
|
-
bottom: 0 !important;
|
|
2041
|
-
left: 0 !important;
|
|
2042
|
-
right: 0 !important;
|
|
2043
|
-
transform: none !important;
|
|
2044
|
-
margin: 0 !important;
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
dialog[data-passkey] iframe {
|
|
2048
|
-
animation: passkey_slideFromBottom 0.3s cubic-bezier(0.32, 0.72, 0, 1);
|
|
2049
|
-
border-bottom-left-radius: 0 !important;
|
|
2050
|
-
border-bottom-right-radius: 0 !important;
|
|
2051
|
-
width: 100% !important;
|
|
2052
|
-
max-height: 90vh !important;
|
|
2053
|
-
max-height: 90dvh !important;
|
|
2054
|
-
box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15) !important;
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
@keyframes passkey_zoomIn {
|
|
2059
|
-
from {
|
|
2060
|
-
opacity: 0;
|
|
2061
|
-
transform: scale(0.96) translateY(8px);
|
|
2062
|
-
}
|
|
2063
|
-
to {
|
|
2064
|
-
opacity: 1;
|
|
2065
|
-
transform: scale(1) translateY(0);
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
@keyframes passkey_slideFromBottom {
|
|
2070
|
-
from { transform: translate3d(0, 100%, 0); }
|
|
2071
|
-
to { transform: translate3d(0, 0, 0); }
|
|
2072
|
-
}
|
|
2073
|
-
|
|
2074
|
-
@keyframes passkey_shake {
|
|
2075
|
-
0%, 100% { transform: translateX(0); }
|
|
2076
|
-
20% { transform: translateX(-4px); }
|
|
2077
|
-
40% { transform: translateX(4px); }
|
|
2078
|
-
60% { transform: translateX(-4px); }
|
|
2079
|
-
80% { transform: translateX(4px); }
|
|
2030
|
+
pointer-events: auto;
|
|
2080
2031
|
}
|
|
2081
2032
|
`;
|
|
2082
2033
|
dialog.appendChild(style);
|
|
2083
2034
|
const iframe = document.createElement("iframe");
|
|
2084
2035
|
iframe.setAttribute(
|
|
2085
2036
|
"allow",
|
|
2086
|
-
|
|
2037
|
+
[
|
|
2038
|
+
`publickey-credentials-get ${hostUrl.origin}`,
|
|
2039
|
+
`publickey-credentials-create ${hostUrl.origin}`,
|
|
2040
|
+
"clipboard-write",
|
|
2041
|
+
"identity-credentials-get"
|
|
2042
|
+
].join("; ")
|
|
2087
2043
|
);
|
|
2088
2044
|
iframe.setAttribute("aria-label", "Passkey Authentication");
|
|
2089
2045
|
iframe.setAttribute("tabindex", "0");
|
|
2046
|
+
iframe.setAttribute(
|
|
2047
|
+
"sandbox",
|
|
2048
|
+
"allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"
|
|
2049
|
+
);
|
|
2090
2050
|
iframe.setAttribute("src", url);
|
|
2091
2051
|
iframe.setAttribute("title", "Passkey");
|
|
2092
|
-
iframe.style.
|
|
2093
|
-
iframe.style.height = "400px";
|
|
2094
|
-
iframe.style.width = `${MODAL_WIDTH}px`;
|
|
2052
|
+
iframe.style.opacity = "0";
|
|
2095
2053
|
dialog.appendChild(iframe);
|
|
2054
|
+
const inertObserver = new MutationObserver((mutations) => {
|
|
2055
|
+
for (const mutation of mutations) {
|
|
2056
|
+
if (mutation.attributeName === "inert") {
|
|
2057
|
+
dialog.removeAttribute("inert");
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
inertObserver.observe(dialog, { attributes: true });
|
|
2096
2062
|
const handleMessage = (event) => {
|
|
2097
2063
|
if (event.origin !== hostUrl.origin) return;
|
|
2098
|
-
if (event.data?.type === "
|
|
2099
|
-
|
|
2100
|
-
iframe.style.
|
|
2101
|
-
}
|
|
2064
|
+
if (event.data?.type === "PASSKEY_RENDERED") {
|
|
2065
|
+
dialog.style.opacity = "1";
|
|
2066
|
+
iframe.style.opacity = "1";
|
|
2067
|
+
}
|
|
2068
|
+
if (event.data?.type === "PASSKEY_DISCONNECT") {
|
|
2102
2069
|
localStorage.removeItem("1auth-user");
|
|
2103
2070
|
}
|
|
2104
2071
|
};
|
|
@@ -2109,19 +2076,22 @@ var OneAuthClient = class {
|
|
|
2109
2076
|
}
|
|
2110
2077
|
};
|
|
2111
2078
|
document.addEventListener("keydown", handleEscape);
|
|
2112
|
-
dialog.addEventListener("click", (event) => {
|
|
2113
|
-
if (event.target === dialog) {
|
|
2114
|
-
cleanup();
|
|
2115
|
-
}
|
|
2116
|
-
});
|
|
2117
2079
|
dialog.showModal();
|
|
2118
2080
|
let cleanedUp = false;
|
|
2119
2081
|
const cleanup = () => {
|
|
2120
2082
|
if (cleanedUp) return;
|
|
2121
2083
|
cleanedUp = true;
|
|
2084
|
+
inertObserver.disconnect();
|
|
2122
2085
|
window.removeEventListener("message", handleMessage);
|
|
2123
2086
|
document.removeEventListener("keydown", handleEscape);
|
|
2124
2087
|
dialog.close();
|
|
2088
|
+
if (dialog.parentNode) {
|
|
2089
|
+
for (const sibling of Array.from(dialog.parentNode.children)) {
|
|
2090
|
+
if (sibling !== dialog && sibling instanceof HTMLElement && sibling.hasAttribute("inert")) {
|
|
2091
|
+
sibling.removeAttribute("inert");
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2125
2095
|
dialog.remove();
|
|
2126
2096
|
};
|
|
2127
2097
|
return { dialog, iframe, cleanup };
|
|
@@ -2137,7 +2107,8 @@ var OneAuthClient = class {
|
|
|
2137
2107
|
dialogReady = true;
|
|
2138
2108
|
iframe.contentWindow?.postMessage({
|
|
2139
2109
|
type: "PASSKEY_INIT",
|
|
2140
|
-
mode: "iframe"
|
|
2110
|
+
mode: "iframe",
|
|
2111
|
+
fullViewport: true
|
|
2141
2112
|
}, dialogOrigin);
|
|
2142
2113
|
return;
|
|
2143
2114
|
}
|