@rhinestone/1auth 0.6.0 → 0.6.1
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/index.js +90 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2163,9 +2163,23 @@ var OneAuthClient = class {
|
|
|
2163
2163
|
createModalDialog(url) {
|
|
2164
2164
|
const dialogUrl = this.getDialogUrl();
|
|
2165
2165
|
const hostUrl = new URL(dialogUrl);
|
|
2166
|
+
const urlParams = new URL(url, window.location.href).searchParams;
|
|
2167
|
+
const themeMode = urlParams.get("theme") || "light";
|
|
2168
|
+
const accentColor = urlParams.get("accent") || "#0090ff";
|
|
2169
|
+
const isDark = themeMode === "dark" || themeMode !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
2170
|
+
const bgPrimary = isDark ? "#191919" : "#fcfcfc";
|
|
2171
|
+
const bgSecondary = isDark ? "#222222" : "#f9f9f9";
|
|
2172
|
+
const borderColor = isDark ? "#2a2a2a" : "#e0e0e0";
|
|
2173
|
+
const textPrimary = isDark ? "#eeeeee" : "#202020";
|
|
2174
|
+
const textSecondary = isDark ? "#7b7b7b" : "#838383";
|
|
2175
|
+
const bgSurface = isDark ? "#222222" : "#f0f0f0";
|
|
2176
|
+
const ah = accentColor.replace("#", "");
|
|
2177
|
+
const accentRgb = `${parseInt(ah.slice(0, 2), 16)},${parseInt(ah.slice(2, 4), 16)},${parseInt(ah.slice(4, 6), 16)}`;
|
|
2178
|
+
const accentTint = isDark ? `rgba(${accentRgb},0.15)` : `rgba(${accentRgb},0.1)`;
|
|
2179
|
+
const hostname = window.location.hostname;
|
|
2166
2180
|
const dialog = document.createElement("dialog");
|
|
2167
2181
|
dialog.dataset.passkey = "";
|
|
2168
|
-
dialog.style.opacity = "
|
|
2182
|
+
dialog.style.opacity = "1";
|
|
2169
2183
|
dialog.style.background = "transparent";
|
|
2170
2184
|
document.body.appendChild(dialog);
|
|
2171
2185
|
const style = document.createElement("style");
|
|
@@ -2183,6 +2197,7 @@ var OneAuthClient = class {
|
|
|
2183
2197
|
padding: 0;
|
|
2184
2198
|
border: none;
|
|
2185
2199
|
background: transparent;
|
|
2200
|
+
color-scheme: normal;
|
|
2186
2201
|
outline: none;
|
|
2187
2202
|
overflow: hidden;
|
|
2188
2203
|
pointer-events: auto;
|
|
@@ -2198,10 +2213,76 @@ var OneAuthClient = class {
|
|
|
2198
2213
|
height: 100%;
|
|
2199
2214
|
border: 0;
|
|
2200
2215
|
background-color: transparent;
|
|
2216
|
+
color-scheme: normal;
|
|
2201
2217
|
pointer-events: auto;
|
|
2218
|
+
backdrop-filter: blur(8px);
|
|
2219
|
+
-webkit-backdrop-filter: blur(8px);
|
|
2220
|
+
}
|
|
2221
|
+
dialog[data-passkey] [data-passkey-overlay] {
|
|
2222
|
+
position: fixed;
|
|
2223
|
+
top: 0;
|
|
2224
|
+
left: 0;
|
|
2225
|
+
width: 100%;
|
|
2226
|
+
height: 100%;
|
|
2227
|
+
display: flex;
|
|
2228
|
+
align-items: flex-start;
|
|
2229
|
+
justify-content: center;
|
|
2230
|
+
padding-top: 50px;
|
|
2231
|
+
background: rgba(0, 0, 0, 0.4);
|
|
2232
|
+
backdrop-filter: blur(8px);
|
|
2233
|
+
-webkit-backdrop-filter: blur(8px);
|
|
2234
|
+
z-index: 1;
|
|
2235
|
+
animation: _1auth-backdrop-in 0.2s ease-out;
|
|
2236
|
+
}
|
|
2237
|
+
@media (max-width: 768px) {
|
|
2238
|
+
dialog[data-passkey] [data-passkey-overlay] {
|
|
2239
|
+
align-items: flex-end;
|
|
2240
|
+
padding-top: 0;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
dialog[data-passkey] [data-passkey-card] {
|
|
2244
|
+
width: 340px;
|
|
2245
|
+
overflow: hidden;
|
|
2246
|
+
border-radius: 14px;
|
|
2247
|
+
box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
|
|
2248
|
+
animation: _1auth-card-in 0.2s cubic-bezier(0.32, 0.72, 0, 1);
|
|
2249
|
+
max-height: calc(100dvh - 100px);
|
|
2250
|
+
}
|
|
2251
|
+
@media (max-width: 768px) {
|
|
2252
|
+
dialog[data-passkey] [data-passkey-card] {
|
|
2253
|
+
width: 100%;
|
|
2254
|
+
border-bottom-left-radius: 0;
|
|
2255
|
+
border-bottom-right-radius: 0;
|
|
2256
|
+
animation: _1auth-card-slide 0.3s cubic-bezier(0.32, 0.72, 0, 1);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
@keyframes _1auth-backdrop-in {
|
|
2260
|
+
from { opacity: 0; } to { opacity: 1; }
|
|
2261
|
+
}
|
|
2262
|
+
@keyframes _1auth-card-in {
|
|
2263
|
+
from { opacity: 0; transform: scale(0.96) translateY(8px); }
|
|
2264
|
+
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
2265
|
+
}
|
|
2266
|
+
@keyframes _1auth-card-slide {
|
|
2267
|
+
from { transform: translate3d(0, 100%, 0); }
|
|
2268
|
+
to { transform: translate3d(0, 0, 0); }
|
|
2269
|
+
}
|
|
2270
|
+
@keyframes _1auth-spin {
|
|
2271
|
+
from { transform: rotate(0deg); }
|
|
2272
|
+
to { transform: rotate(360deg); }
|
|
2202
2273
|
}
|
|
2203
2274
|
`;
|
|
2204
2275
|
dialog.appendChild(style);
|
|
2276
|
+
const overlay = document.createElement("div");
|
|
2277
|
+
overlay.dataset.passkeyOverlay = "";
|
|
2278
|
+
const _sp = '<path d="M10 0.5C8.02219 0.5 6.08879 1.08649 4.4443 2.1853C2.79981 3.28412 1.51809 4.8459 0.761209 6.67316C0.00433288 8.50043 -0.1937 10.5111 0.192152 12.4509C0.578004 14.3907 1.53041 16.1725 2.92894 17.5711C4.32746 18.9696 6.10929 19.922 8.0491 20.3078C9.98891 20.6937 11.9996 20.4957 13.8268 19.7388C15.6541 18.9819 17.2159 17.7002 18.3147 16.0557C19.4135 14.4112 20 12.4778 20 10.5C20 7.84783 18.9464 5.3043 17.0711 3.42893C15.1957 1.55357 12.6522 0.5 10 0.5ZM10 17.7727C8.56159 17.7727 7.15549 17.3462 5.95949 16.547C4.7635 15.7479 3.83134 14.6121 3.28088 13.2831C2.73042 11.9542 2.5864 10.4919 2.86702 9.08116C3.14764 7.67039 3.8403 6.37451 4.85741 5.3574C5.87452 4.3403 7.17039 3.64764 8.58116 3.36702C9.99193 3.0864 11.4542 3.23042 12.7832 3.78088C14.1121 4.33133 15.2479 5.26349 16.0471 6.45949C16.8462 7.65548 17.2727 9.06159 17.2727 10.5C17.2727 12.4288 16.5065 14.2787 15.1426 15.6426C13.7787 17.0065 11.9288 17.7727 10 17.7727Z" fill="currentColor" opacity="0.3"/><path d="M10 3.22767C11.7423 3.22846 13.4276 3.8412 14.7556 4.95667C16.0837 6.07214 16.9681 7.61784 17.2512 9.31825C17.3012 9.64364 17.4662 9.94096 17.7169 10.1573C17.9677 10.3737 18.2878 10.4951 18.6205 10.5C18.8211 10.5001 19.0193 10.457 19.2012 10.3735C19.3832 10.2901 19.5445 10.1684 19.674 10.017C19.8036 9.86549 19.8981 9.68789 19.9511 9.49656C20.004 9.30523 20.0141 9.10478 19.9807 8.90918C19.5986 6.56305 18.3843 4.42821 16.5554 2.88726C14.7265 1.34631 12.4025 0.5 10 0.5C7.59751 0.5 5.27354 1.34631 3.44461 2.88726C1.61569 4.42821 0.401366 6.56305 0.0192815 8.90918C-0.0141442 9.10478 -0.00402016 9.30523 0.0489472 9.49656C0.101914 9.68789 0.196449 9.86549 0.325956 10.017C0.455463 10.1684 0.616823 10.2901 0.798778 10.3735C0.980732 10.457 1.1789 10.5001 1.37945 10.5C1.71216 10.4951 2.03235 10.3737 2.28307 10.1573C2.5338 9.94096 2.69883 9.64364 2.74882 9.31825C3.03193 7.61784 3.91633 6.07214 5.24436 4.95667C6.57239 3.8412 8.25775 3.22846 10 3.22767Z" fill="currentColor"/>';
|
|
2279
|
+
overlay.innerHTML = `<div data-passkey-card style="background:${bgPrimary};border:1px solid ${borderColor};font-family:ui-sans-serif,system-ui,sans-serif,'Apple Color Emoji','Segoe UI Emoji'"><div style="height:36px;display:flex;align-items:center;justify-content:space-between;padding:0 12px;background:${bgSecondary};border-bottom:1px solid ${borderColor}"><div style="display:flex;align-items:center;gap:8px"><div style="display:flex;width:20px;height:20px;align-items:center;justify-content:center;border-radius:4px;background:${bgSurface}"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="${textPrimary}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12V7H5a2 2 0 0 1 0-4h14v4"/><path d="M3 5v14a2 2 0 0 0 2 2h16v-5"/><path d="M18 12a2 2 0 0 0 0 4h4v-4Z"/></svg></div><span style="font-size:13px;font-weight:500;color:${textPrimary};max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${hostname}</span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="${textSecondary}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/><path d="m9 12 2 2 4-4"/></svg></div><div style="display:flex;align-items:center;gap:4px"><div style="display:flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:6px;color:${textSecondary}"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg></div><button data-passkey-close style="display:flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:6px;color:${textSecondary};border:none;background:none;cursor:pointer;padding:0"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button></div></div><div style="padding:12px"><div style="display:flex;align-items:center;gap:8px"><div style="display:flex;width:32px;height:32px;min-width:32px;align-items:center;justify-content:center;border-radius:50%;background:${accentTint};padding:6px"><svg style="width:100%;height:100%;animation:_1auth-spin 0.8s linear infinite;color:${accentColor}" fill="none" viewBox="0 0 20 21" xmlns="http://www.w3.org/2000/svg">${_sp}</svg></div><div style="font-weight:500;font-size:18px;color:${textPrimary}">Loading...</div></div><div style="margin-top:8px"><div style="font-size:15px;line-height:20px;color:${textPrimary}">This will only take a few moments.</div><div style="font-size:15px;line-height:20px;color:${textSecondary}">Please do not close the window.</div></div></div></div>`;
|
|
2280
|
+
overlay.addEventListener("click", (e) => {
|
|
2281
|
+
if (e.target === overlay) cleanup();
|
|
2282
|
+
});
|
|
2283
|
+
const overlayCloseBtn = overlay.querySelector("[data-passkey-close]");
|
|
2284
|
+
if (overlayCloseBtn) overlayCloseBtn.addEventListener("click", () => cleanup());
|
|
2285
|
+
dialog.appendChild(overlay);
|
|
2205
2286
|
const iframe = document.createElement("iframe");
|
|
2206
2287
|
iframe.setAttribute(
|
|
2207
2288
|
"allow",
|
|
@@ -2230,11 +2311,17 @@ var OneAuthClient = class {
|
|
|
2230
2311
|
}
|
|
2231
2312
|
});
|
|
2232
2313
|
inertObserver.observe(dialog, { attributes: true });
|
|
2314
|
+
let overlayHidden = false;
|
|
2315
|
+
const hideOverlay = () => {
|
|
2316
|
+
if (overlayHidden) return;
|
|
2317
|
+
overlayHidden = true;
|
|
2318
|
+
overlay.style.display = "none";
|
|
2319
|
+
iframe.style.opacity = "1";
|
|
2320
|
+
};
|
|
2233
2321
|
const handleMessage = (event) => {
|
|
2234
2322
|
if (event.origin !== hostUrl.origin) return;
|
|
2235
2323
|
if (event.data?.type === "PASSKEY_RENDERED") {
|
|
2236
|
-
|
|
2237
|
-
iframe.style.opacity = "1";
|
|
2324
|
+
hideOverlay();
|
|
2238
2325
|
}
|
|
2239
2326
|
if (event.data?.type === "PASSKEY_DISCONNECT") {
|
|
2240
2327
|
localStorage.removeItem("1auth-user");
|