@rhinestone/1auth 0.7.1 → 0.7.3

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
@@ -8,7 +8,12 @@ import {
8
8
  } from "./chunk-IHBVEU33.mjs";
9
9
  import {
10
10
  createOneAuthProvider
11
- } from "./chunk-THKG3FAG.mjs";
11
+ } from "./chunk-UXBBB7AV.mjs";
12
+ import {
13
+ buildTransactionReview,
14
+ encodeWebAuthnSignature,
15
+ hashCalls
16
+ } from "./chunk-N6KE5CII.mjs";
12
17
  import {
13
18
  getAllSupportedChainsAndTokens,
14
19
  getChainById,
@@ -26,11 +31,6 @@ import {
26
31
  isTokenAddressSupported,
27
32
  resolveTokenAddress
28
33
  } from "./chunk-GUAI55LL.mjs";
29
- import {
30
- buildTransactionReview,
31
- encodeWebAuthnSignature,
32
- hashCalls
33
- } from "./chunk-N6KE5CII.mjs";
34
34
 
35
35
  // src/client.ts
36
36
  import { hashTypedData } from "viem";
@@ -163,7 +163,7 @@ var POPUP_WIDTH = LOADING_MODAL_WIDTH;
163
163
  var POPUP_HEIGHT = 600;
164
164
  var DEFAULT_EMBED_WIDTH = `${LOADING_MODAL_WIDTH}px`;
165
165
  var DEFAULT_EMBED_HEIGHT = "500px";
166
- var DEFAULT_PROVIDER_URL = "https://passkey.1auth.box";
166
+ var DEFAULT_PROVIDER_URL = "https://passkey.1auth.app";
167
167
  function currentWindowOrigin() {
168
168
  if (typeof window === "undefined") return null;
169
169
  const origin = window.location?.origin;
@@ -619,7 +619,7 @@ var OneAuthClient = class {
619
619
  * Falls back to the raw dialog URL string if URL parsing fails (e.g. during
620
620
  * unit tests with non-standard URL formats).
621
621
  *
622
- * @returns The scheme + host + optional port of the dialog app (e.g. `"https://passkey.1auth.box"`).
622
+ * @returns The scheme + host + optional port of the dialog app (e.g. `"https://passkey.1auth.app"`).
623
623
  */
624
624
  getDialogOrigin() {
625
625
  const dialogUrl = this.getDialogUrl();
@@ -1670,7 +1670,7 @@ var OneAuthClient = class {
1670
1670
  };
1671
1671
  const handleMessage = (event) => {
1672
1672
  if (event.origin !== dialogOrigin) return;
1673
- if (event.data?.type === "PASSKEY_CLOSE") {
1673
+ if (event.data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
1674
1674
  resolveClosed(iframeReadyObserved);
1675
1675
  }
1676
1676
  };
@@ -2369,7 +2369,7 @@ var OneAuthClient = class {
2369
2369
  const dialogOrigin2 = this.getDialogOrigin();
2370
2370
  const earlyCloseHandler = (event) => {
2371
2371
  if (event.origin !== dialogOrigin2) return;
2372
- if (event.data?.type === "PASSKEY_CLOSE") {
2372
+ if (event.data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
2373
2373
  userClosedEarly = true;
2374
2374
  cleanup();
2375
2375
  }
@@ -2984,7 +2984,7 @@ var OneAuthClient = class {
2984
2984
  * @param cleanup - Idempotent teardown function that closes and removes the dialog.
2985
2985
  * @returns A `SigningResult` discriminated union.
2986
2986
  */
2987
- waitForIntentSigningResponse(requestId, dialog, _iframe, cleanup) {
2987
+ waitForIntentSigningResponse(requestId, dialog, iframe, cleanup) {
2988
2988
  const dialogOrigin = this.getDialogOrigin();
2989
2989
  return new Promise((resolve) => {
2990
2990
  const handleMessage = (event) => {
@@ -3010,7 +3010,7 @@ var OneAuthClient = class {
3010
3010
  }
3011
3011
  });
3012
3012
  }
3013
- } else if (message?.type === "PASSKEY_CLOSE") {
3013
+ } else if (message?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
3014
3014
  window.removeEventListener("message", handleMessage);
3015
3015
  cleanup();
3016
3016
  resolve({
@@ -3041,12 +3041,13 @@ var OneAuthClient = class {
3041
3041
  * forward to the execute endpoint.
3042
3042
  *
3043
3043
  * @param dialog - The `<dialog>` element wrapping the signing iframe.
3044
- * @param _iframe - Unused; kept for signature consistency with other wait helpers.
3044
+ * @param iframe - The signing iframe; used to authenticate the source of
3045
+ * `PASSKEY_CLOSE` so a sibling same-origin dialog can't forge a rejection.
3045
3046
  * @param cleanup - Idempotent teardown that closes and removes the dialog.
3046
3047
  * @returns A `SigningResult` extended with an optional `signedHash` field
3047
3048
  * populated when the dialog performs message signing.
3048
3049
  */
3049
- waitForSigningResponse(dialog, _iframe, cleanup) {
3050
+ waitForSigningResponse(dialog, iframe, cleanup) {
3050
3051
  const dialogOrigin = this.getDialogOrigin();
3051
3052
  return new Promise((resolve) => {
3052
3053
  const handleMessage = (event) => {
@@ -3077,7 +3078,7 @@ var OneAuthClient = class {
3077
3078
  }
3078
3079
  });
3079
3080
  }
3080
- } else if (message?.type === "PASSKEY_CLOSE") {
3081
+ } else if (message?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
3081
3082
  window.removeEventListener("message", handleMessage);
3082
3083
  cleanup();
3083
3084
  resolve({
@@ -3160,7 +3161,7 @@ var OneAuthClient = class {
3160
3161
  }
3161
3162
  });
3162
3163
  }
3163
- } else if (message?.type === "PASSKEY_CLOSE") {
3164
+ } else if (message?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
3164
3165
  window.removeEventListener("message", handleMessage);
3165
3166
  cleanup();
3166
3167
  resolve({
@@ -3410,7 +3411,7 @@ var OneAuthClient = class {
3410
3411
  );
3411
3412
  }
3412
3413
  });
3413
- } else if (event.data?.type === "PASSKEY_CLOSE") {
3414
+ } else if (event.data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
3414
3415
  teardown();
3415
3416
  cleanup();
3416
3417
  resolve({ ready: false });
@@ -4433,7 +4434,7 @@ var OneAuthClient = class {
4433
4434
  blindSigning
4434
4435
  }, dialogOrigin);
4435
4436
  resolve(true);
4436
- } else if (event.data?.type === "PASSKEY_CLOSE") {
4437
+ } else if (event.data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
4437
4438
  teardown();
4438
4439
  cleanup();
4439
4440
  resolve(false);
@@ -5076,7 +5077,7 @@ var OneAuthClient = class {
5076
5077
  message: "Permission grant failed"
5077
5078
  }
5078
5079
  });
5079
- } else if (data?.type === "PASSKEY_CLOSE") {
5080
+ } else if (data?.type === "PASSKEY_CLOSE" && event.source === iframe.contentWindow) {
5080
5081
  teardown();
5081
5082
  cleanup();
5082
5083
  resolve({