@rhinestone/1auth 0.6.0 → 0.6.2

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.mjs CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  isTestnet,
19
19
  isTokenAddressSupported,
20
20
  resolveTokenAddress
21
- } from "./chunk-N4BLW5UR.mjs";
21
+ } from "./chunk-IP2FG4WQ.mjs";
22
22
 
23
23
  // src/client.ts
24
24
  import { parseUnits, hashTypedData } from "viem";
@@ -214,6 +214,53 @@ var OneAuthClient = class {
214
214
  }
215
215
  return this.waitForConnectResponse(dialog, iframe, cleanup);
216
216
  }
217
+ /**
218
+ * Open the account management dialog.
219
+ *
220
+ * Shows the account overview with guardian status and recovery setup
221
+ * options. The dialog closes when the user clicks the X button or
222
+ * completes their action.
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * await client.openAccountDialog();
227
+ * ```
228
+ */
229
+ async openAccountDialog(options) {
230
+ const dialogUrl = this.getDialogUrl();
231
+ const params = new URLSearchParams({
232
+ mode: "iframe"
233
+ });
234
+ const themeParams = this.getThemeParams(options?.theme);
235
+ if (themeParams) {
236
+ const themeParsed = new URLSearchParams(themeParams);
237
+ themeParsed.forEach((value, key) => params.set(key, value));
238
+ }
239
+ const url = `${dialogUrl}/dialog/account?${params.toString()}`;
240
+ const { dialog, iframe, cleanup } = this.createModalDialog(url);
241
+ const ready = await this.waitForDialogReady(dialog, iframe, cleanup, {
242
+ mode: "iframe"
243
+ });
244
+ if (!ready) return;
245
+ const dialogOrigin = this.getDialogOrigin();
246
+ return new Promise((resolve) => {
247
+ const handleMessage = (event) => {
248
+ if (event.origin !== dialogOrigin) return;
249
+ if (event.data?.type === "PASSKEY_CLOSE" || event.data?.type === "PASSKEY_DISCONNECT") {
250
+ window.removeEventListener("message", handleMessage);
251
+ dialog.removeEventListener("close", handleClose);
252
+ cleanup();
253
+ resolve();
254
+ }
255
+ };
256
+ const handleClose = () => {
257
+ window.removeEventListener("message", handleMessage);
258
+ resolve();
259
+ };
260
+ window.addEventListener("message", handleMessage);
261
+ dialog.addEventListener("close", handleClose);
262
+ });
263
+ }
217
264
  /**
218
265
  * Check if a user has already granted consent for the requested fields.
219
266
  * This is a read-only check — no dialog is shown.
@@ -509,10 +556,13 @@ var OneAuthClient = class {
509
556
  const themeParams = this.getThemeParams();
510
557
  const signingUrl = `${dialogUrl}/dialog/sign?mode=iframe${themeParams ? `&${themeParams}` : ""}`;
511
558
  const { dialog, iframe, cleanup } = this.createModalDialog(signingUrl);
512
- const [prepareResult, dialogResult] = await Promise.all([
513
- this.prepareIntent(requestBody),
514
- this.waitForDialogReadyDeferred(dialog, iframe, cleanup)
515
- ]);
559
+ const dialogOrigin = this.getDialogOrigin();
560
+ let earlyPrepareResult = null;
561
+ const preparePromise = this.prepareIntent(requestBody).then((r) => {
562
+ earlyPrepareResult = r;
563
+ return r;
564
+ });
565
+ const dialogResult = await this.waitForDialogReadyDeferred(dialog, iframe, cleanup);
516
566
  if (!dialogResult.ready) {
517
567
  return {
518
568
  success: false,
@@ -521,40 +571,85 @@ var OneAuthClient = class {
521
571
  error: { code: "USER_CANCELLED", message: "User closed the dialog" }
522
572
  };
523
573
  }
524
- if (!prepareResult.success) {
525
- this.sendPrepareError(iframe, prepareResult.error.message);
526
- await this.waitForDialogClose(dialog, cleanup);
527
- return {
528
- success: false,
529
- intentId: "",
530
- status: "failed",
531
- error: prepareResult.error
574
+ let currentInitPayload;
575
+ if (earlyPrepareResult) {
576
+ const prepareResult = earlyPrepareResult;
577
+ if (!prepareResult.success) {
578
+ this.sendPrepareError(iframe, prepareResult.error.message);
579
+ await this.waitForDialogClose(dialog, cleanup);
580
+ return {
581
+ success: false,
582
+ intentId: "",
583
+ status: "failed",
584
+ error: prepareResult.error
585
+ };
586
+ }
587
+ prepareResponse = prepareResult.data;
588
+ currentInitPayload = {
589
+ mode: "iframe",
590
+ calls,
591
+ chainId: targetChain,
592
+ transaction: prepareResponse.transaction,
593
+ challenge: prepareResponse.challenge,
594
+ username,
595
+ accountAddress: prepareResponse.accountAddress,
596
+ originMessages: prepareResponse.originMessages,
597
+ tokenRequests: serializedTokenRequests,
598
+ expiresAt: prepareResponse.expiresAt,
599
+ userId: prepareResponse.userId,
600
+ intentOp: prepareResponse.intentOp,
601
+ digestResult: prepareResponse.digestResult,
602
+ tier: prepareResult.tier
603
+ };
604
+ dialogResult.sendInit(currentInitPayload);
605
+ } else {
606
+ currentInitPayload = {
607
+ mode: "iframe",
608
+ calls,
609
+ chainId: targetChain,
610
+ username,
611
+ accountAddress: options.accountAddress,
612
+ tokenRequests: serializedTokenRequests
532
613
  };
614
+ dialogResult.sendInit(currentInitPayload);
615
+ const prepareResult = await preparePromise;
616
+ if (!prepareResult.success) {
617
+ this.sendPrepareError(iframe, prepareResult.error.message);
618
+ await this.waitForDialogClose(dialog, cleanup);
619
+ return {
620
+ success: false,
621
+ intentId: "",
622
+ status: "failed",
623
+ error: prepareResult.error
624
+ };
625
+ }
626
+ prepareResponse = prepareResult.data;
627
+ currentInitPayload = {
628
+ mode: "iframe",
629
+ calls,
630
+ chainId: targetChain,
631
+ transaction: prepareResponse.transaction,
632
+ challenge: prepareResponse.challenge,
633
+ username,
634
+ accountAddress: prepareResponse.accountAddress,
635
+ originMessages: prepareResponse.originMessages,
636
+ tokenRequests: serializedTokenRequests,
637
+ expiresAt: prepareResponse.expiresAt,
638
+ userId: prepareResponse.userId,
639
+ intentOp: prepareResponse.intentOp,
640
+ digestResult: prepareResponse.digestResult,
641
+ tier: prepareResult.tier
642
+ };
643
+ iframe.contentWindow?.postMessage(
644
+ { type: "PASSKEY_INIT", ...currentInitPayload, fullViewport: true },
645
+ dialogOrigin
646
+ );
533
647
  }
534
- prepareResponse = prepareResult.data;
535
- const dialogOrigin = this.getDialogOrigin();
536
- const initPayload = {
537
- mode: "iframe",
538
- calls,
539
- chainId: targetChain,
540
- transaction: prepareResponse.transaction,
541
- challenge: prepareResponse.challenge,
542
- username,
543
- accountAddress: prepareResponse.accountAddress,
544
- originMessages: prepareResponse.originMessages,
545
- tokenRequests: serializedTokenRequests,
546
- expiresAt: prepareResponse.expiresAt,
547
- userId: prepareResponse.userId,
548
- intentOp: prepareResponse.intentOp,
549
- digestResult: prepareResponse.digestResult,
550
- tier: prepareResult.tier
551
- };
552
- dialogResult.sendInit(initPayload);
553
648
  const handleReReady = (event) => {
554
649
  if (event.origin !== dialogOrigin) return;
555
650
  if (event.data?.type === "PASSKEY_READY") {
556
651
  iframe.contentWindow?.postMessage(
557
- { type: "PASSKEY_INIT", ...initPayload, fullViewport: true },
652
+ { type: "PASSKEY_INIT", ...currentInitPayload, fullViewport: true },
558
653
  dialogOrigin
559
654
  );
560
655
  }
@@ -843,10 +938,13 @@ var OneAuthClient = class {
843
938
  const themeParams = this.getThemeParams();
844
939
  const signingUrl = `${dialogUrl}/dialog/sign?mode=iframe${themeParams ? `&${themeParams}` : ""}`;
845
940
  const { dialog, iframe, cleanup } = this.createModalDialog(signingUrl);
846
- const [prepareResult, dialogResult] = await Promise.all([
847
- this.prepareBatchIntent(requestBody),
848
- this.waitForDialogReadyDeferred(dialog, iframe, cleanup)
849
- ]);
941
+ const dialogOrigin = this.getDialogOrigin();
942
+ let earlyBatchResult = null;
943
+ const preparePromise = this.prepareBatchIntent(requestBody).then((r) => {
944
+ earlyBatchResult = r;
945
+ return r;
946
+ });
947
+ const dialogResult = await this.waitForDialogReadyDeferred(dialog, iframe, cleanup);
850
948
  if (!dialogResult.ready) {
851
949
  return {
852
950
  success: false,
@@ -855,7 +953,8 @@ var OneAuthClient = class {
855
953
  failureCount: 0
856
954
  };
857
955
  }
858
- if (!prepareResult.success) {
956
+ let currentBatchPayload;
957
+ const handleBatchPrepareFailure = async (prepareResult) => {
859
958
  const failedIntents = prepareResult.failedIntents;
860
959
  const failureResults = failedIntents?.map((f) => ({
861
960
  index: f.index,
@@ -873,27 +972,68 @@ var OneAuthClient = class {
873
972
  failureCount: failureResults.length,
874
973
  error: prepareResult.error
875
974
  };
876
- }
877
- let prepareResponse = prepareResult.data;
878
- const dialogOrigin = this.getDialogOrigin();
879
- const batchInitPayload = {
880
- mode: "iframe",
881
- batchMode: true,
882
- batchIntents: prepareResponse.intents,
883
- batchFailedIntents: prepareResponse.failedIntents,
884
- challenge: prepareResponse.challenge,
885
- username: options.username,
886
- accountAddress: prepareResponse.accountAddress,
887
- userId: prepareResponse.userId,
888
- expiresAt: prepareResponse.expiresAt,
889
- tier: prepareResult.tier
890
975
  };
891
- dialogResult.sendInit(batchInitPayload);
976
+ let prepareResponse;
977
+ if (earlyBatchResult) {
978
+ const prepareResult = earlyBatchResult;
979
+ if (!prepareResult.success) {
980
+ return handleBatchPrepareFailure(prepareResult);
981
+ }
982
+ prepareResponse = prepareResult.data;
983
+ currentBatchPayload = {
984
+ mode: "iframe",
985
+ batchMode: true,
986
+ batchIntents: prepareResponse.intents,
987
+ batchFailedIntents: prepareResponse.failedIntents,
988
+ challenge: prepareResponse.challenge,
989
+ username: options.username,
990
+ accountAddress: prepareResponse.accountAddress,
991
+ userId: prepareResponse.userId,
992
+ expiresAt: prepareResponse.expiresAt,
993
+ tier: prepareResult.tier
994
+ };
995
+ dialogResult.sendInit(currentBatchPayload);
996
+ } else {
997
+ currentBatchPayload = {
998
+ mode: "iframe",
999
+ batchMode: true,
1000
+ batchIntents: serializedIntents.map((intent, idx) => ({
1001
+ index: idx,
1002
+ targetChain: intent.targetChain,
1003
+ calls: JSON.stringify(intent.calls)
1004
+ // No: transaction, intentOp, expiresAt, originMessages
1005
+ })),
1006
+ username: options.username,
1007
+ accountAddress: options.accountAddress
1008
+ };
1009
+ dialogResult.sendInit(currentBatchPayload);
1010
+ const prepareResult = await preparePromise;
1011
+ if (!prepareResult.success) {
1012
+ return handleBatchPrepareFailure(prepareResult);
1013
+ }
1014
+ prepareResponse = prepareResult.data;
1015
+ currentBatchPayload = {
1016
+ mode: "iframe",
1017
+ batchMode: true,
1018
+ batchIntents: prepareResponse.intents,
1019
+ batchFailedIntents: prepareResponse.failedIntents,
1020
+ challenge: prepareResponse.challenge,
1021
+ username: options.username,
1022
+ accountAddress: prepareResponse.accountAddress,
1023
+ userId: prepareResponse.userId,
1024
+ expiresAt: prepareResponse.expiresAt,
1025
+ tier: prepareResult.tier
1026
+ };
1027
+ iframe.contentWindow?.postMessage(
1028
+ { type: "PASSKEY_INIT", ...currentBatchPayload, fullViewport: true },
1029
+ dialogOrigin
1030
+ );
1031
+ }
892
1032
  const handleBatchReReady = (event) => {
893
1033
  if (event.origin !== dialogOrigin) return;
894
1034
  if (event.data?.type === "PASSKEY_READY") {
895
1035
  iframe.contentWindow?.postMessage(
896
- { type: "PASSKEY_INIT", ...batchInitPayload, fullViewport: true },
1036
+ { type: "PASSKEY_INIT", ...currentBatchPayload, fullViewport: true },
897
1037
  dialogOrigin
898
1038
  );
899
1039
  }
@@ -1631,16 +1771,8 @@ var OneAuthClient = class {
1631
1771
  const themeParams = this.getThemeParams(options?.theme);
1632
1772
  const signingUrl = `${dialogUrl}/dialog/sign?mode=iframe${themeParams ? `&${themeParams}` : ""}`;
1633
1773
  const { dialog, iframe, cleanup } = this.createModalDialog(signingUrl);
1634
- const ready = await this.waitForDialogReady(dialog, iframe, cleanup, {
1635
- mode: "iframe",
1636
- message: options.message,
1637
- challenge: options.challenge || options.message,
1638
- username: options.username,
1639
- accountAddress: options.accountAddress,
1640
- description: options.description,
1641
- metadata: options.metadata
1642
- });
1643
- if (!ready) {
1774
+ const dialogResult = await this.waitForDialogReadyDeferred(dialog, iframe, cleanup);
1775
+ if (!dialogResult.ready) {
1644
1776
  return {
1645
1777
  success: false,
1646
1778
  error: {
@@ -1649,7 +1781,29 @@ var OneAuthClient = class {
1649
1781
  }
1650
1782
  };
1651
1783
  }
1784
+ const initPayload = {
1785
+ mode: "iframe",
1786
+ message: options.message,
1787
+ challenge: options.challenge || options.message,
1788
+ username: options.username,
1789
+ accountAddress: options.accountAddress,
1790
+ description: options.description,
1791
+ metadata: options.metadata
1792
+ };
1793
+ dialogResult.sendInit(initPayload);
1794
+ const dialogOrigin = this.getDialogOrigin();
1795
+ const handleReReady = (event) => {
1796
+ if (event.origin !== dialogOrigin) return;
1797
+ if (event.data?.type === "PASSKEY_READY") {
1798
+ iframe.contentWindow?.postMessage(
1799
+ { type: "PASSKEY_INIT", ...initPayload, fullViewport: true },
1800
+ dialogOrigin
1801
+ );
1802
+ }
1803
+ };
1804
+ window.addEventListener("message", handleReReady);
1652
1805
  const signingResult = await this.waitForSigningResponse(dialog, iframe, cleanup);
1806
+ window.removeEventListener("message", handleReReady);
1653
1807
  cleanup();
1654
1808
  if (signingResult.success) {
1655
1809
  return {
@@ -1717,7 +1871,17 @@ var OneAuthClient = class {
1717
1871
  const themeParams = this.getThemeParams(options?.theme);
1718
1872
  const signingUrl = `${dialogUrl}/dialog/sign?mode=iframe${themeParams ? `&${themeParams}` : ""}`;
1719
1873
  const { dialog, iframe, cleanup } = this.createModalDialog(signingUrl);
1720
- const ready = await this.waitForDialogReady(dialog, iframe, cleanup, {
1874
+ const dialogResult = await this.waitForDialogReadyDeferred(dialog, iframe, cleanup);
1875
+ if (!dialogResult.ready) {
1876
+ return {
1877
+ success: false,
1878
+ error: {
1879
+ code: "USER_REJECTED",
1880
+ message: "User closed the dialog"
1881
+ }
1882
+ };
1883
+ }
1884
+ const initPayload = {
1721
1885
  mode: "iframe",
1722
1886
  signingMode: "typedData",
1723
1887
  typedData: {
@@ -1730,17 +1894,21 @@ var OneAuthClient = class {
1730
1894
  username: options.username,
1731
1895
  accountAddress: options.accountAddress,
1732
1896
  description: options.description
1733
- });
1734
- if (!ready) {
1735
- return {
1736
- success: false,
1737
- error: {
1738
- code: "USER_REJECTED",
1739
- message: "User closed the dialog"
1740
- }
1741
- };
1742
- }
1897
+ };
1898
+ dialogResult.sendInit(initPayload);
1899
+ const dialogOrigin = this.getDialogOrigin();
1900
+ const handleReReady = (event) => {
1901
+ if (event.origin !== dialogOrigin) return;
1902
+ if (event.data?.type === "PASSKEY_READY") {
1903
+ iframe.contentWindow?.postMessage(
1904
+ { type: "PASSKEY_INIT", ...initPayload, fullViewport: true },
1905
+ dialogOrigin
1906
+ );
1907
+ }
1908
+ };
1909
+ window.addEventListener("message", handleReReady);
1743
1910
  const signingResult = await this.waitForSigningResponse(dialog, iframe, cleanup);
1911
+ window.removeEventListener("message", handleReReady);
1744
1912
  cleanup();
1745
1913
  if (signingResult.success) {
1746
1914
  return {
@@ -1992,9 +2160,23 @@ var OneAuthClient = class {
1992
2160
  createModalDialog(url) {
1993
2161
  const dialogUrl = this.getDialogUrl();
1994
2162
  const hostUrl = new URL(dialogUrl);
2163
+ const urlParams = new URL(url, window.location.href).searchParams;
2164
+ const themeMode = urlParams.get("theme") || "light";
2165
+ const accentColor = urlParams.get("accent") || "#0090ff";
2166
+ const isDark = themeMode === "dark" || themeMode !== "light" && window.matchMedia("(prefers-color-scheme: dark)").matches;
2167
+ const bgPrimary = isDark ? "#191919" : "#fcfcfc";
2168
+ const bgSecondary = isDark ? "#222222" : "#f9f9f9";
2169
+ const borderColor = isDark ? "#2a2a2a" : "#e0e0e0";
2170
+ const textPrimary = isDark ? "#eeeeee" : "#202020";
2171
+ const textSecondary = isDark ? "#7b7b7b" : "#838383";
2172
+ const bgSurface = isDark ? "#222222" : "#f0f0f0";
2173
+ const ah = accentColor.replace("#", "");
2174
+ const accentRgb = `${parseInt(ah.slice(0, 2), 16)},${parseInt(ah.slice(2, 4), 16)},${parseInt(ah.slice(4, 6), 16)}`;
2175
+ const accentTint = isDark ? `rgba(${accentRgb},0.15)` : `rgba(${accentRgb},0.1)`;
2176
+ const hostname = window.location.hostname;
1995
2177
  const dialog = document.createElement("dialog");
1996
2178
  dialog.dataset.passkey = "";
1997
- dialog.style.opacity = "0";
2179
+ dialog.style.opacity = "1";
1998
2180
  dialog.style.background = "transparent";
1999
2181
  document.body.appendChild(dialog);
2000
2182
  const style = document.createElement("style");
@@ -2012,6 +2194,7 @@ var OneAuthClient = class {
2012
2194
  padding: 0;
2013
2195
  border: none;
2014
2196
  background: transparent;
2197
+ color-scheme: normal;
2015
2198
  outline: none;
2016
2199
  overflow: hidden;
2017
2200
  pointer-events: auto;
@@ -2027,10 +2210,76 @@ var OneAuthClient = class {
2027
2210
  height: 100%;
2028
2211
  border: 0;
2029
2212
  background-color: transparent;
2213
+ color-scheme: normal;
2030
2214
  pointer-events: auto;
2215
+ backdrop-filter: blur(8px);
2216
+ -webkit-backdrop-filter: blur(8px);
2217
+ }
2218
+ dialog[data-passkey] [data-passkey-overlay] {
2219
+ position: fixed;
2220
+ top: 0;
2221
+ left: 0;
2222
+ width: 100%;
2223
+ height: 100%;
2224
+ display: flex;
2225
+ align-items: flex-start;
2226
+ justify-content: center;
2227
+ padding-top: 50px;
2228
+ background: rgba(0, 0, 0, 0.4);
2229
+ backdrop-filter: blur(8px);
2230
+ -webkit-backdrop-filter: blur(8px);
2231
+ z-index: 1;
2232
+ animation: _1auth-backdrop-in 0.2s ease-out;
2233
+ }
2234
+ @media (max-width: 768px) {
2235
+ dialog[data-passkey] [data-passkey-overlay] {
2236
+ align-items: flex-end;
2237
+ padding-top: 0;
2238
+ }
2239
+ }
2240
+ dialog[data-passkey] [data-passkey-card] {
2241
+ width: 340px;
2242
+ overflow: hidden;
2243
+ border-radius: 14px;
2244
+ box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
2245
+ animation: _1auth-card-in 0.2s cubic-bezier(0.32, 0.72, 0, 1);
2246
+ max-height: calc(100dvh - 100px);
2247
+ }
2248
+ @media (max-width: 768px) {
2249
+ dialog[data-passkey] [data-passkey-card] {
2250
+ width: 100%;
2251
+ border-bottom-left-radius: 0;
2252
+ border-bottom-right-radius: 0;
2253
+ animation: _1auth-card-slide 0.3s cubic-bezier(0.32, 0.72, 0, 1);
2254
+ }
2255
+ }
2256
+ @keyframes _1auth-backdrop-in {
2257
+ from { opacity: 0; } to { opacity: 1; }
2258
+ }
2259
+ @keyframes _1auth-card-in {
2260
+ from { opacity: 0; transform: scale(0.96) translateY(8px); }
2261
+ to { opacity: 1; transform: scale(1) translateY(0); }
2262
+ }
2263
+ @keyframes _1auth-card-slide {
2264
+ from { transform: translate3d(0, 100%, 0); }
2265
+ to { transform: translate3d(0, 0, 0); }
2266
+ }
2267
+ @keyframes _1auth-spin {
2268
+ from { transform: rotate(0deg); }
2269
+ to { transform: rotate(360deg); }
2031
2270
  }
2032
2271
  `;
2033
2272
  dialog.appendChild(style);
2273
+ const overlay = document.createElement("div");
2274
+ overlay.dataset.passkeyOverlay = "";
2275
+ 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"/>';
2276
+ 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>`;
2277
+ overlay.addEventListener("click", (e) => {
2278
+ if (e.target === overlay) cleanup();
2279
+ });
2280
+ const overlayCloseBtn = overlay.querySelector("[data-passkey-close]");
2281
+ if (overlayCloseBtn) overlayCloseBtn.addEventListener("click", () => cleanup());
2282
+ dialog.appendChild(overlay);
2034
2283
  const iframe = document.createElement("iframe");
2035
2284
  iframe.setAttribute(
2036
2285
  "allow",
@@ -2059,11 +2308,19 @@ var OneAuthClient = class {
2059
2308
  }
2060
2309
  });
2061
2310
  inertObserver.observe(dialog, { attributes: true });
2311
+ let overlayHidden = false;
2312
+ const hideOverlay = () => {
2313
+ if (overlayHidden) return;
2314
+ overlayHidden = true;
2315
+ iframe.style.opacity = "1";
2316
+ requestAnimationFrame(() => {
2317
+ overlay.style.display = "none";
2318
+ });
2319
+ };
2062
2320
  const handleMessage = (event) => {
2063
2321
  if (event.origin !== hostUrl.origin) return;
2064
2322
  if (event.data?.type === "PASSKEY_RENDERED") {
2065
- dialog.style.opacity = "1";
2066
- iframe.style.opacity = "1";
2323
+ hideOverlay();
2067
2324
  }
2068
2325
  if (event.data?.type === "PASSKEY_DISCONNECT") {
2069
2326
  localStorage.removeItem("1auth-user");
@@ -3134,7 +3391,8 @@ function BatchQueueWidget({ onSignAll }) {
3134
3391
  import { keccak256, toBytes } from "viem";
3135
3392
  var ETHEREUM_MESSAGE_PREFIX = "Ethereum Signed Message:\n";
3136
3393
  function hashMessage2(message) {
3137
- const prefixed = ETHEREUM_MESSAGE_PREFIX + message.length.toString() + message;
3394
+ const messageBytes = toBytes(message);
3395
+ const prefixed = ETHEREUM_MESSAGE_PREFIX + messageBytes.length.toString() + message;
3138
3396
  return keccak256(toBytes(prefixed));
3139
3397
  }
3140
3398
  function verifyMessageHash(message, signedHash) {